<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML+RDFa 1.1//EN' 'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd'>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" prefix='bibo: http://purl.org/ontology/bibo/' typeof="bibo:Document">
<head>
<title>JSON-LD Algorithms 1.0</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<!--
  === NOTA BENE ===
  For the three scripts below, if your spec resides on dev.w3 you can check them
  out in the same tree and use relative links so that they'll work offline,
  -->




<style type="text/css">
  .diff { font-weight:bold; color:#0a3; }
</style>
<style>/*****************************************************************
 * ReSpec 3 CSS
 * Robin Berjon - http://berjon.com/
 *****************************************************************/

/* --- INLINES --- */
em.rfc2119 { 
    text-transform:     lowercase;
    font-variant:       small-caps;
    font-style:         normal;
    color:              #900;
}

h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
    border: none;
}

dfn {
    font-weight:    bold;
}

a.internalDFN {
    color:  inherit;
    border-bottom:  1px solid #99c;
    text-decoration:    none;
}

a.externalDFN {
    color:  inherit;
    border-bottom:  1px dotted #ccc;
    text-decoration:    none;
}

a.bibref {
    text-decoration:    none;
}

cite .bibref {
    font-style: normal;
}

code {
    color:  #ff4500;
}


/* --- --- */
ol.algorithm { counter-reset:numsection; list-style-type: none; }
ol.algorithm li { margin: 0.5em 0; }
ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }

/* --- TOC --- */
.toc a, .tof a {
    text-decoration:    none;
}

a .secno, a .figno {
    color:  #000;
}

ul.tof, ol.tof {
    list-style: none outside none;
}

.caption {
    margin-top: 0.5em;
    font-style:   italic;
}

/* --- TABLE --- */
table.simple {
    border-spacing: 0;
    border-collapse:    collapse;
    border-bottom:  3px solid #005a9c;
}

.simple th {
    background: #005a9c;
    color:  #fff;
    padding:    3px 5px;
    text-align: left;
}

.simple th[scope="row"] {
    background: inherit;
    color:  inherit;
    border-top: 1px solid #ddd;
}

.simple td {
    padding:    3px 10px;
    border-top: 1px solid #ddd;
}

.simple tr:nth-child(even) {
    background: #f0f6ff;
}

/* --- DL --- */
.section dd > p:first-child {
    margin-top: 0;
}

.section dd > p:last-child {
    margin-bottom: 0;
}

.section dd {
    margin-bottom:  1em;
}

.section dl.attrs dd, .section dl.eldef dd {
    margin-bottom:  0;
}
</style><style>/* --- EXAMPLES --- */
div.example-title {
    min-width: 7.5em;
    color: #b9ab2d;
}
div.example-title span {
    text-transform: uppercase;   
}
aside.example, div.example, div.illegal-example {
    padding: 0.5em;
    margin: 1em 0;
    position: relative;
    clear: both;
}
div.illegal-example { color: red }
div.illegal-example p { color: black }
aside.example, div.example {
    padding: .5em;
    border-left-width: .5em;
    border-left-style: solid;
    border-color: #e0cb52;
    background: #fcfaee;    
}

aside.example div.example {
    border-left-width: .1em;
    border-color: #999;
    background: #fff;
}
aside.example div.example div.example-title {
    color: #999;
}
</style><style>/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title {
    padding-right:  1em;
    min-width: 7.5em;
    color: #b9ab2d;
}
div.issue-title { color: #e05252; }
div.note-title { color: #52e052; }
div.issue-title span, div.note-title span {
    text-transform: uppercase;
}
div.note, div.issue {
    margin-top: 1em;
    margin-bottom: 1em;
}
.note > p:first-child, .issue > p:first-child { margin-top: 0 }
.issue, .note {
    padding: .5em;
    border-left-width: .5em;
    border-left-style: solid;
}
div.issue, div.note {
    padding: 0.5em;
    margin: 1em 0;
    position: relative;
    clear: both;
}
span.note, span.issue { padding: .1em .5em .15em; }

.issue {
    border-color: #e05252;
    background: #fbe9e9;
}
.note {
    border-color: #52e052;
    background: #e9fbe9;
}


</style><style>/* --- WEB IDL --- */
pre.idl {
    border-top: 1px solid #90b8de;
    border-bottom: 1px solid #90b8de;
    padding:    1em;
    line-height:    120%;
}

pre.idl::before {
    content:    "WebIDL";
    display:    block;
    width:      150px;
    background: #90b8de;
    color:  #fff;
    font-family:    initial;
    padding:    3px;
    font-weight:    bold;
    margin: -1em 0 1em -1em;
}

.idlType {
    color:  #ff4500;
    font-weight:    bold;
    text-decoration:    none;
}

/*.idlModule*/
/*.idlModuleID*/
/*.idlInterface*/
.idlInterfaceID, .idlDictionaryID, .idlCallbackID, .idlEnumID {
    font-weight:    bold;
    color:  #005a9c;
}

.idlSuperclass {
    font-style: italic;
    color:  #005a9c;
}

/*.idlAttribute*/
.idlAttrType, .idlFieldType, .idlMemberType {
    color:  #005a9c;
}
.idlAttrName, .idlFieldName, .idlMemberName {
    color:  #ff4500;
}
.idlAttrName a, .idlFieldName a, .idlMemberName a {
    color:  #ff4500;
    border-bottom:  1px dotted #ff4500;
    text-decoration: none;
}

/*.idlMethod*/
.idlMethType, .idlCallbackType {
    color:  #005a9c;
}
.idlMethName {
    color:  #ff4500;
}
.idlMethName a {
    color:  #ff4500;
    border-bottom:  1px dotted #ff4500;
    text-decoration: none;
}

/*.idlParam*/
.idlParamType {
    color:  #005a9c;
}
.idlParamName {
    font-style: italic;
}

.extAttr {
    color:  #666;
}

/*.idlConst*/
.idlConstType {
    color:  #005a9c;
}
.idlConstName {
    color:  #ff4500;
}
.idlConstName a {
    color:  #ff4500;
    border-bottom:  1px dotted #ff4500;
    text-decoration: none;
}

/*.idlException*/
.idlExceptionID {
    font-weight:    bold;
    color:  #c00;
}

.idlTypedefID, .idlTypedefType {
    color:  #005a9c;
}

.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code {
    color:  #c00;
    font-weight:    normal;
}

.excName a {
    font-family:    monospace;
}

.idlRaises a.idlType, .excName a.idlType {
    border-bottom:  1px dotted #c00;
}

.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse {
    width:  45px;
    text-align: center;
}
.excGetSetTrue, .prmNullTrue, .prmOptTrue { color:  #0c0; }
.excGetSetFalse, .prmNullFalse, .prmOptFalse { color:  #c00; }

.idlImplements a {
    font-weight:    bold;
}

dl.attributes, dl.methods, dl.constants, dl.fields, dl.dictionary-members {
    margin-left:    2em;
}

.attributes dt, .methods dt, .constants dt, .fields dt, .dictionary-members dt {
    font-weight:    normal;
}

.attributes dt code, .methods dt code, .constants dt code, .fields dt code, .dictionary-members dt code {
    font-weight:    bold;
    color:  #000;
    font-family:    monospace;
}

.attributes dt code, .fields dt code, .dictionary-members dt code {
    background:  #ffffd2;
}

.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code {
    color:  #005a9c;
    background:  transparent;
    font-family:    inherit;
    font-weight:    normal;
    font-style: italic;
}

.methods dt code {
    background:  #d9e6f8;
}

.constants dt code {
    background:  #ddffd2;
}

.attributes dd, .methods dd, .constants dd, .fields dd, .dictionary-members dd {
    margin-bottom:  1em;
}

table.parameters, table.exceptions {
    border-spacing: 0;
    border-collapse:    collapse;
    margin: 0.5em 0;
    width:  100%;
}
table.parameters { border-bottom:  1px solid #90b8de; }
table.exceptions { border-bottom:  1px solid #deb890; }

.parameters th, .exceptions th {
    color:  #fff;
    padding:    3px 5px;
    text-align: left;
    font-family:    initial;
    font-weight:    normal;
    text-shadow:    #666 1px 1px 0;
}
.parameters th { background: #90b8de; }
.exceptions th { background: #deb890; }

.parameters td, .exceptions td {
    padding:    3px 10px;
    border-top: 1px solid #ddd;
    vertical-align: top;
}

.parameters tr:first-child td, .exceptions tr:first-child td {
    border-top: none;
}

.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName {
    width:  100px;
}

.parameters td.prmType {
    width:  120px;
}

table.exceptions table {
    border-spacing: 0;
    border-collapse:    collapse;
    width:  100%;
}
</style><link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-ED" />
<!--[if lt IE 9]><script src='http://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]-->
</head>

<body><div class="head">
  <p>
    
      <a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C" /></a>
    
  </p>
  <h1 class="title" id="title">JSON-LD Algorithms 1.0</h1>
  
    <h2 id="subtitle">Algorithms for Processing JSON-LD Documents</h2>
  
  <h2 id="w3c-editor-s-draft-25-december-2012"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 25 December 2012</h2>
  <dl>
    
      <dt>This version:</dt>
      <dd><a href="http://dvcs.w3.org/hg/json-ld/raw-file/default/spec/ED/json-ld-api/20121225/index.html">http://dvcs.w3.org/hg/json-ld/raw-file/default/spec/ED/json-ld-api/20121225/index.html</a></dd>
      <dt>Latest published version:</dt>
      <dd><a href="http://www.w3.org/TR/json-ld-api/">http://www.w3.org/TR/json-ld-api/</a></dd>
    
    
      <dt>Latest editor's draft:</dt>
      <dd><a href="http://dvcs.w3.org/hg/json-ld/raw-file/default/spec/latest/json-ld-api/index.html">http://dvcs.w3.org/hg/json-ld/raw-file/default/spec/latest/json-ld-api/index.html</a></dd>
    
    
    
    
      
    
    
    
    <dt>Editors:</dt>
    <dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Manu Sporny" href="http://manu.sporny.org/">Manu Sporny</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Gregg Kellogg" href="http://greggkellogg.net/">Gregg Kellogg</a>, <a rel="foaf:workplaceHomepage" href="http://kellogg-assoc.com/">Kellogg Associates</a></span>
</dd>
<dd rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Markus Lanthaler" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a>, <a rel="foaf:workplaceHomepage" href="http://www.tugraz.at/">Graz University of Technology</a></span>
</dd>

    
      <dt>Authors:</dt>
      <dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Dave Longley" href="http://digitalbazaar.com/">Dave Longley</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Manu Sporny" href="http://digitalbazaar.com/">Manu Sporny</a>, <a rel="foaf:workplaceHomepage" href="http://digitalbazaar.com/">Digital Bazaar</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Gregg Kellogg" href="http://greggkellogg.net/">Gregg Kellogg</a>, <a rel="foaf:workplaceHomepage" href="http://kellogg-assoc.com/">Kellogg Associates</a></span>
</dd>
<dd rel="dcterms:contributor"><span typeof="foaf:Person"><a rel="foaf:homepage" property="foaf:name" content="Markus Lanthaler" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a>, <a rel="foaf:workplaceHomepage" href="http://www.tugraz.at/">Graz University of Technology</a></span>
</dd>

    
  </dl>
  
  
    <p>
      
        This document is also available in this non-normative format: 
      
      <a href="diff-20120930.html">diff to previous version</a>
    </p>
  
  
  
    
      <p class="copyright">
        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 
        2010-2012
        
        <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> 
        (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
        <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
        <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
        <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
        <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
      </p>
    
  
  <hr />
</div>
<section id="abstract" class="introductory" property="dcterms:abstract" datatype="" typeof="bibo:Chapter" resource="#abstract" rel="bibo:chapter"><h2>Abstract</h2>
<p>
JSON [<cite><a class="bibref" href="#bib-RFC4627">RFC4627</a></cite>] has proven to be a highly useful object serialization and
messaging format. JSON-LD [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>] harmonizes the representation of
Linked Data in JSON by outlining a common JSON representation format for
expressing directed graphs; mixing both Linked Data and non-Linked Data in
a single document. This document outlines an Application Programming
Interface and a set of algorithms for programmatically transforming
JSON-LD documents in order to make them easier to work with in programming
environments like JavaScript, Python, and Ruby.
</p>
</section><section id="sotd" class="introductory" typeof="bibo:Chapter" resource="#sotd" rel="bibo:chapter"><h2>Status of This Document</h2>
  
    
      
        <p>
          <em>This section describes the status of this document at the time of its publication. Other
          documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision
          of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports
          index</a> at http://www.w3.org/TR/.</em>
        </p>
        
<p>This document has been under development for over 18 months in the
JSON for Linking Data Community Group. The document has recently been
transferred to the RDF Working Group for review, improvement, and publication
along the Recommendation track. The specification has undergone significant
development, review, and changes during the course of the last 18 months.
</p>
<p>There are several independent
<a href="http://json-ld.org/#impl">interoperable implementations</a> of
this specification. There is
a <a href="https://github.com/json-ld/json-ld.org/tree/main/test-suite">fairly complete test suite</a>
and a <a href="http://json-ld.org/playground/">live JSON-LD editor</a>
that is capable of demonstrating the features described in
this document. While development on implementations, the test suite
and the live editor will continue, they are believed to be mature enough
to be integrated into a non-production system at this point in time with
the expectation that they could be used in a production system within the
next year.
</p>
<div class="issue"><div class="issue-title"><span>Issue</span></div><p class="">
It is important for readers to understand that the scope of this document is
currently under debate and new features may be added to the specification.
Existing features may be modified heavily or removed entirely from the
specification upon further review and feedback from the broader community.
This is a work in progress and publication as a Working Draft
does not require that all Working Group members agree on the content of the
document.
</p></div>

<p>There are a number of ways that one may participate in the development of
  this specification:</p>

<ul>
  <li>If you want to make sure that your feedback is formally addressed by
    the RDF Working Group, you should send it to public-rdf-comments:
    <a href="http://lists.w3.org/Archives/Public/public-rdf-comments/">public-rdf-comments@w3.org</a></li>

  <li>Ad-hoc technical discussion primarily occurs on the public community mailing list:
    <a href="http://lists.w3.org/Archives/Public/public-linked-json/">public-linked-json@w3.org</a></li>

  <li><a href="http://json-ld.org/minutes/">Public JSON-LD Community Group teleconferences</a>
  are held on Tuesdays at 1500UTC every week. Participation is open to the
  public.</li>

  <li>RDF Working Group teleconferences are held on Wednesdays at 1500UTC
  every week. Participation is limited to RDF Working Group members.</li>

  <li>Specification bugs and issues should be reported in the
    <a href="https://github.com/json-ld/json-ld.org/issues">issue tracker</a>
    if you do not want to send an e-mail to the public-rdf-comments mailing
    list.</li>

  <li><a href="https://github.com/json-ld/json-ld.org/tree/main/spec">Source code</a>
    for the specification can be found on Github.</li>

  <li>The <a href="http://webchat.freenode.net/?channels=json-ld">#json-ld</a>
    IRC channel is available for real-time discussion on irc.freenode.net.</li>
</ul>


        <p>
          This document was published by the <a href="http://www.w3.org/2011/rdf-wg/">RDF Working Group</a> as an Editor's Draft.
          
          If you wish to make comments regarding this document, please send them to 
          <a href="mailto:public-rdf-comments@w3.org">public-rdf-comments@w3.org</a> 
          (<a href="mailto:public-rdf-comments-request@w3.org?subject=subscribe">subscribe</a>,
          <a href="http://lists.w3.org/Archives/Public/public-rdf-comments/">archives</a>).
          
          
          All feedback is welcome.
        </p>
        
          <p>
            Publication as an Editor's Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership.
            This is a draft document and may be updated, replaced or obsoleted by other documents at 
            any time. It is inappropriate to cite this document as other than work in progress.
          </p>
        
        
        <p>
          
            This document was produced by a group operating under the 
            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
          
          
          
            
              <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/46168/status" rel="disclosure">public list of any patent disclosures</a> 
            
            made in connection with the deliverables of the group; that page also includes instructions for 
            disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
            information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
            6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
          
          
        </p>
        
      
    
  
</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a></li><li class="tocline"><a href="#features" class="tocxref"><span class="secno">2. </span>Features</a><ul class="toc"><li class="tocline"><a href="#expansion" class="tocxref"><span class="secno">2.1 </span>Expansion</a></li><li class="tocline"><a href="#compaction" class="tocxref"><span class="secno">2.2 </span>Compaction</a></li><li class="tocline"><a href="#flattening" class="tocxref"><span class="secno">2.3 </span>Flattening</a></li><li class="tocline"><a href="#rdf-conversion" class="tocxref"><span class="secno">2.4 </span>RDF Conversion</a></li></ul></li><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">3. </span>Conformance</a></li><li class="tocline"><a href="#general-terminology" class="tocxref"><span class="secno">4. </span>General Terminology</a></li><li class="tocline"><a href="#algorithms" class="tocxref"><span class="secno">5. </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#algorithm-terms" class="tocxref"><span class="secno">5.1 </span>Algorithm Terms</a></li><li class="tocline"><a href="#expansion-algorithm" class="tocxref"><span class="secno">5.2 </span>Expansion Algorithm</a></li><li class="tocline"><a href="#context-processing" class="tocxref"><span class="secno">5.3 </span>Context Processing</a></li><li class="tocline"><a href="#iri-expansion" class="tocxref"><span class="secno">5.4 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</a></li><li class="tocline"><a href="#value-expansion" class="tocxref"><span class="secno">5.5 </span>Value Expansion</a></li><li class="tocline"><a href="#label-blank-nodes-algorithm" class="tocxref"><span class="secno">5.6 </span>Label Blank Nodes Algorithm</a></li><li class="tocline"><a href="#generate-blank-node-identifier" class="tocxref"><span class="secno">5.7 </span>Generate Blank Node Identifier</a></li><li class="tocline"><a href="#compaction-algorithm" class="tocxref"><span class="secno">5.8 </span>Compaction Algorithm</a></li><li class="tocline"><a href="#iri-compaction-algorithm" class="tocxref"><span class="secno">5.9 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction Algorithm</a></li><li class="tocline"><a href="#inverse-context-creation" class="tocxref"><span class="secno">5.10 </span>Inverse Context Creation</a></li><li class="tocline"><a href="#inverse-context-query-algorithm" class="tocxref"><span class="secno">5.11 </span>Inverse Context Query Algorithm</a></li><li class="tocline"><a href="#value-compaction" class="tocxref"><span class="secno">5.12 </span>Value Compaction</a></li><li class="tocline"><a href="#find-and-remove-property-generator-duplicates" class="tocxref"><span class="secno">5.13 </span>Find and Remove Property Generator Duplicates</a></li><li class="tocline"><a href="#flattening-algorithm" class="tocxref"><span class="secno">5.14 </span>Flattening Algorithm</a></li><li class="tocline"><a href="#node-map-generation" class="tocxref"><span class="secno">5.15 </span>Node Map Generation</a></li><li class="tocline"><a href="#rdf-conversion-algorithms" class="tocxref"><span class="secno">5.16 </span>RDF Conversion Algorithms</a><ul class="toc"><li class="tocline"><a href="#convert-to-rdf-algorithm" class="tocxref"><span class="secno">5.16.1 </span>Convert to RDF Algorithm</a></li><li class="tocline"><a href="#list-conversion" class="tocxref"><span class="secno">5.16.2 </span>List Conversion</a></li><li class="tocline"><a href="#convert-from-rdf-algorithm" class="tocxref"><span class="secno">5.16.3 </span>Convert from RDF Algorithm</a></li><li class="tocline"><a href="#data-round-tripping" class="tocxref"><span class="secno">5.16.4 </span>Data Round Tripping</a></li></ul></li></ul></li><li class="tocline"><a href="#the-application-programming-interface" class="tocxref"><span class="secno">6. </span>The Application Programming Interface</a><ul class="toc"><li class="tocline"><a href="#jsonldprocessor" class="tocxref"><span class="secno">6.1 </span>JsonLdProcessor</a><ul class="toc"><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">6.1.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#callbacks" class="tocxref"><span class="secno">6.2 </span>Callbacks</a><ul class="toc"><li class="tocline"><a href="#jsonldcallback" class="tocxref"><span class="secno">6.2.1 </span>JsonLdCallback</a></li></ul></li><li class="tocline"><a href="#data-structures" class="tocxref"><span class="secno">6.3 </span>Data Structures</a><ul class="toc"><li class="tocline"><a href="#jsonldoptions" class="tocxref"><span class="secno">6.3.1 </span>JsonLdOptions</a></li><li class="tocline"><a href="#jsonldprocessingerror" class="tocxref"><span class="secno">6.3.2 </span>JsonLdProcessingError</a></li><li class="tocline"><a href="#jsonlderrorcode" class="tocxref"><span class="secno">6.3.3 </span>JsonLdErrorCode</a></li></ul></li></ul></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">A. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">B. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">B.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">B.2 </span>Informative references</a></li></ul></li></ul></section>



<section class="informative" id="introduction">

<!--OddPage-->
<h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>

<p>
This document is a detailed specification for an Application Programming
Interface for the JSON-LD Syntax. The document is primarily intended for
the following audiences:
</p>

<ul>
  <li>Web authors and developers that want a very detailed view of how
  a JSON-LD processor and the API operates.</li>
  <li>Software developers that want to implement processors and APIs for
  JSON-LD.</li>
</ul>

<p>
To understand the basics in this specification you must first be familiar with
JSON, which is detailed in [<cite><a class="bibref" href="#bib-RFC4627">RFC4627</a></cite>]. You must also understand the
JSON-LD Syntax [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>], which is the base syntax used by all of the
algorithms in this document. To understand the API and how it is
intended to operate in a programming environment, it is useful to have working
knowledge of the JavaScript programming language [<cite><a class="bibref" href="#bib-ECMA-262">ECMA-262</a></cite>] and
WebIDL [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]. To understand how JSON-LD maps to RDF, it is helpful to be
familiar with the basic RDF concepts [<cite><a class="bibref" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>].</p>

</section>

<section class="informative" id="features">

<!--OddPage-->
<h2><span class="secno">2. </span>Features</h2><p><em>This section is non-normative.</em></p>

<p>The JSON-LD Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>] outlines a language that may be
  used to express Linked Data in JSON. Often, it is useful to be able to transform
  JSON-LD documents so that they may be easily processed in various programming
  environments.</p>

<p>There are four major types of transformation that are discussed in this document:
  expansion, compaction, flattening, and RDF conversion.</p>

<section class="informative" id="expansion">
  <h3><span class="secno">2.1 </span>Expansion</h3><p><em>This section is non-normative.</em></p>
  <p>Software algorithms are easiest to write when the data that they are processing
    have a regular form. Since information can be represented by JSON-LD in a
    variety of different ways, transforming all of these methods into a uniform
    structure allows the developer to simplify their processing code. For example,
    note that the following input uses only <a class="tref internalDFN" title="term" href="#dfn-term">term</a>s and is fairly
    compact:</p>

  <div class="example"><div class="example-title"><span>Example 1</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;name&quot;: &quot;http://xmlns.com/foaf/0.1/name&quot;,
    &quot;homepage&quot;: {
      &quot;@id&quot;: &quot;http://xmlns.com/foaf/0.1/homepage&quot;,
      &quot;@type&quot;: &quot;@id&quot;
    }
  },
  &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
  &quot;name&quot;: &quot;Markus Lanthaler&quot;,
  &quot;homepage&quot;: &quot;http://www.markus-lanthaler.com/&quot;
}</pre></div>

  <p>The next input example uses one <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> to express a property, but leaves
    the rest of the information untouched.</p>

  <div class="example"><div class="example-title"><span>Example 2</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;homepage&quot;: {
      &quot;@id&quot;: &quot;http://xmlns.com/foaf/0.1/homepage&quot;,
      &quot;@type&quot;: &quot;@id&quot;
    }
  },
  &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
  &quot;<span class="diff">http://xmlns.com/foaf/0.1/name</span>&quot;: &quot;Markus Lanthaler&quot;,
  &quot;homepage&quot;: &quot;http://www.markus-lanthaler.com/&quot;
}</pre></div>

  <p>While both inputs are valid JSON-LD, writing a program to handle every
    permutation of possible inputs can be difficult, especially when the incoming
    context could change as well. To ensure that the data can be given a more
    uniform structure, JSON-LD introduces the notion of expansion. <dfn title="expansion" id="dfn-expansion">Expansion</dfn>
    performs two important operations. The first is to expand all values that represent
    <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a> to <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute IRIs</a>.
    The second is to express all values in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a>. Running the
    <a href="#expansion-algorithm">Expansion algorithm</a> against the examples provided
    above results in the following output:</p>

  <div class="example"><div class="example-title"><span>Example 3</span></div><pre class="example">[
  {
    &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      { &quot;@value&quot;: &quot;Markus Lanthaler&quot; }
    ],
    &quot;http://xmlns.com/foaf/0.1/homepage&quot;: [
      { &quot;@id&quot;: &quot;http://www.markus-lanthaler.com/&quot; }
    ]
  }
]</pre></div>

  <p>Note that in the output above all <a class="tref internalDFN" title="context" href="#dfn-context">context</a> definitions have
    been removed, all <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> and <a class="tref internalDFN" title="prefix" href="#dfn-prefix">prefixes</a>
    have been expanded to absolute <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a>, and all
    <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD values</a> are expressed in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a>.
    While the output is more difficult for a human to read, it is easier for a
    software program to process because of its very regular structure.</p>
</section>

<section class="informative" id="compaction">
  <h3><span class="secno">2.2 </span>Compaction</h3><p><em>This section is non-normative.</em></p>
  <p>While expansion expands a given input as much as possible, compaction performs
    the opposite operation: it expresses a given input as succinctly as possible. In contrast
    to expansion which is meant to produce something that is easy to process by software
    programs, compaction is meant to produce something that is easy to read by software
    developers. Compaction uses a developer-supplied <a class="tref internalDFN" title="context" href="#dfn-context">context</a> to compress
    <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a> to <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> or
    <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact IRIs</a> and <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD values</a>
    expressed in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a> to simple values such as
    <a class="tref internalDFN" title="string" href="#dfn-string">strings</a> and <a class="tref internalDFN" title="number" href="#dfn-number">numbers</a>.</p>

  <p>For example, assume the following expanded JSON-LD input document:</p>

  <div class="example"><div class="example-title"><span>Example 4</span></div><pre class="example">[
  {
    &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      { &quot;@value&quot;: &quot;Markus Lanthaler&quot; }
    ],
    &quot;http://xmlns.com/foaf/0.1/homepage&quot;: [
      { &quot;@id&quot;: &quot;http://www.markus-lanthaler.com/&quot; }
    ]
  }
]</pre></div>

  <p>Additionally, assume the following developer-supplied JSON-LD <a class="tref internalDFN" title="context" href="#dfn-context">context</a>:</p>

  <div class="example"><div class="example-title"><span>Example 5</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;name&quot;: &quot;http://xmlns.com/foaf/0.1/name&quot;,
    &quot;homepage&quot;: {
      &quot;@id&quot;: &quot;http://xmlns.com/foaf/0.1/homepage&quot;,
      &quot;@type&quot;: &quot;@id&quot;
    }
  }
}</pre></div>

  <p>Running the <a href="#compaction-algorithm">Compaction Algorithm</a> given the context
    supplied above against the JSON-LD input document provided above would result in the
    following output:</p>

  <div class="example"><div class="example-title"><span>Example 6</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;name&quot;: &quot;http://xmlns.com/foaf/0.1/name&quot;,
    &quot;homepage&quot;: {
      &quot;@id&quot;: &quot;http://xmlns.com/foaf/0.1/homepage&quot;,
      &quot;@type&quot;: &quot;@id&quot;
    }
  },
  &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
  &quot;name&quot;: &quot;Markus Lanthaler&quot;,
  &quot;homepage&quot;: &quot;http://www.markus-lanthaler.com/&quot;
}</pre></div>

  <p>Note that all <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a> have been compacted to
    <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> as specified in the <a class="tref internalDFN" title="context" href="#dfn-context">context</a>
    which consequently has been injected into the output. While compacted
    output is most useful to humans, it can often also be used to generate
    structures that are easy to program against. Compaction enables developers
    to map any expanded document into an application-specific compacted document.
    While the context provided above mapped <code>http://xmlns.com/foaf/0.1/name</code>
    to <code>name</code>, it could have also have been mapped to any other term
    provided by the developer.</p>

</section>

<section class="informative" id="flattening">
  <h3><span class="secno">2.3 </span>Flattening</h3><p><em>This section is non-normative.</em></p>
  <p>While expansion ensures that a document is in a uniform structure, flattening
    goes a step further and ensures that also the shape of the data is deterministic.
    In expanded documents properties of a single <a class="tref internalDFN" title="node" href="#dfn-node">node</a> may still be
    spread across a number of different <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON objects</a>.
    By flattening a document, all properties of a <a class="tref internalDFN" title="node" href="#dfn-node">node</a> are collected in a
    single <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> and all <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank nodes</a>
    are labeled with a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>. Often this drastically
    simplifies the code to process JSON-LD data.</p>

  <p>For example, assume the following JSON-LD input document:</p>

  <div class="example"><div class="example-title"><span>Example 7</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;name&quot;: &quot;http://xmlns.com/foaf/0.1/name&quot;,
    &quot;knows&quot;: &quot;http://xmlns.com/foaf/0.1/knows&quot;
  },
  &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
  &quot;name&quot;: &quot;Markus Lanthaler&quot;,
  &quot;knows&quot;: [
    {
      &quot;name&quot;: &quot;Manu Sporny&quot;,
      &quot;knows&quot;: {
        &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot;
      }
    },
    {
      &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot;,
      &quot;name&quot;: &quot;Gregg Kellogg&quot;
    }
  ]
}</pre></div>

  <p>Running the <a href="#flattening-algorithm">Flattening Algorithm</a>
    with a context set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a> to prevent compaction returns
    the following document:</p>

  <div class="example"><div class="example-title"><span>Example 8</span></div><pre class="example">[
  {
    &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      { &quot;@value&quot;: &quot;Markus Lanthaler&quot; }
    ],
    &quot;http://xmlns.com/foaf/0.1/knows&quot;: [
      { &quot;@id&quot;: &quot;_:t0&quot; },
      { &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot; }
    ]
  },
  {
    &quot;@id&quot;: &quot;_:t0&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      { &quot;@value&quot;: &quot;Manu Sporny&quot; }
    ],
    &quot;http://xmlns.com/foaf/0.1/knows&quot;: [
      { &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot; }
    ]
  },
  {
    &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      { &quot;@value&quot;: &quot;Gregg Kellogg&quot; }
    ]
  }
]</pre></div>

  <p>Note how in the output above all properties of a <a class="tref internalDFN" title="node" href="#dfn-node">node</a> are collected in a
    single <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> and how the <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a> representing
    &quot;Manu Sporny&quot; has been assigned the <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>
    <code>_:t0</code>.</p>

  <p>To make it easier for humans to read such a flattened document can be compacted by
    passing a context. Using the same context as the input document, the flattened
    and compacted document looks as follows:</p>

  <div class="example"><div class="example-title"><span>Example 9</span></div><pre class="example">{
  &quot;@context&quot;: {
    &quot;name&quot;: &quot;http://xmlns.com/foaf/0.1/name&quot;,
    &quot;knows&quot;: &quot;http://xmlns.com/foaf/0.1/knows&quot;
  },
  &quot;@graph&quot;: [
    {
      &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
      &quot;name&quot;: &quot;Markus Lanthaler&quot;,
      &quot;knows&quot;: [
        { &quot;@id&quot;: &quot;_:t0&quot; },
        { &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot; }
      ]
    },
    {
      &quot;@id&quot;: &quot;_:t0&quot;,
      &quot;name&quot;: &quot;Manu Sporny&quot;,
      &quot;knows&quot;: {
        &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot;
      }
    },
    {
      &quot;@id&quot;: &quot;http://greggkellogg.net/foaf#me&quot;,
      &quot;name&quot;: &quot;Gregg Kellogg&quot;
    }
  ]
}</pre></div>

  <p>Please note that the flattened and compacted result will always explicitly
    designate the default by the <code>@graph</code> member in the top-level
    <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>. <a href="#compaction">Compaction</a> optimizes that
    member away if its value contains just one item.</p>
</section>

<section class="informative" id="rdf-conversion">
  <h3><span class="secno">2.4 </span>RDF Conversion</h3><p><em>This section is non-normative.</em></p>
  <p>JSON-LD can be used to serialize data expressed in RDF as described in
    [<cite><a class="bibref" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>]. This ensures that data can be round-tripped from and to
    any RDF syntax without any loss in the fidelity of the data.</p>

  <p>For example, assume the following RDF input serialized in Turtle [<cite><a class="bibref" href="#bib-TURTLE-TR">TURTLE-TR</a></cite>]:</p>

  <div class="example"><div class="example-title"><span>Example 10</span></div><pre class="example">&lt;http://me.markus-lanthaler.com/&gt; &lt;http://xmlns.com/foaf/0.1/name&gt; &quot;Markus Lanthaler&quot; .
&lt;http://me.markus-lanthaler.com/&gt; &lt;http://xmlns.com/foaf/0.1/homepage&gt; &lt;http://www.markus-lanthaler.com/&gt; .</pre></div>

  <p>Using the <a href="#convert-from-rdf-algorithm">Convert from RDF Algorithm</a> a
    developer could transform this document into expanded JSON-LD:</p>

  <div class="example"><div class="example-title"><span>Example 11</span></div><pre class="example">[
  {
    &quot;@id&quot;: &quot;http://me.markus-lanthaler.com/&quot;,
    &quot;http://xmlns.com/foaf/0.1/name&quot;: [
      {
        &quot;@value&quot;: &quot;Markus Lanthaler&quot;
      }
    ],
    &quot;http://xmlns.com/foaf/0.1/homepage&quot;: [
      {
        &quot;@id&quot;: &quot;http://www.markus-lanthaler.com/&quot;
      }
    ]
  }
]</pre></div>

  <p>Note that the output above could easily be compacted using the technique outlined
    in the previous section. It is also possible to transform the JSON-LD document back
    to RDF using the <a href="#convert-to-rdf-algorithm">Convert to RDF Algorithm</a>.</p>
  </section>

</section>

<section id="conformance">
  
<!--OddPage-->
<h2><span class="secno">3. </span>Conformance</h2>

  <p>All examples and notes as well as sections marked as non-normative in this
    specification are non-normative. Everything else in this specification is
    normative.</p>

  <p>The keywords <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should not">should not</em>, <em class="rfc2119" title="recommended">recommended</em>,
    <em class="rfc2119" title="may">may</em>, and <em class="rfc2119" title="optional">optional</em> in this specification are to be interpreted as described
    in [<cite><a class="bibref" href="#bib-RFC2119">RFC2119</a></cite>].</p>

  <p>There are two classes of products that can claim conformance to this
    specification: <a class="tref internalDFN" title="json-ld_implementation" href="#dfn-json-ld_implementation">JSON-LD Implementations</a>
    and <a class="tref internalDFN" title="json-ld_processor" href="#dfn-json-ld_processor">JSON-LD Processors</a>.</p>

  <p>A conforming <dfn title="json-ld_implementation" id="dfn-json-ld_implementation">JSON-LD Implementation</dfn> is a system capable of transforming
    JSON-LD documents according the algorithms defined in this specification.</p>

  <p>A conforming <dfn title="json-ld_processor" id="dfn-json-ld_processor">JSON-LD Processor</dfn> is a conforming <a class="tref internalDFN" title="json-ld_implementation" href="#dfn-json-ld_implementation">JSON-LD Implementation</a>
    that exposes the application programming interface (API) defined in this specification.</p>

  <p>The algorithms in this specification are generally written with more concern for clarity than
    over efficiency. Thus, JSON-LD Implementations and Processors may implement the algorithms
    given in this specification in any way desired, so long as the end result is indistinguishable
    from the result that would be obtained by the specification's algorithms.</p>

  <p>This specification does not define how JSON-LD Implementations or Processors handle
    non-conforming input documents. This implies that JSON-LD Implementations or Processors
    <em class="rfc2119" title="must not">must not</em> attempt to correct malformed IRIs or language tags; however, they <em class="rfc2119" title="may">may</em> issue
    validation warnings.</p>

  <div class="note"><div class="note-title"><span>Note</span></div><p class="">Implementers can partially check their level of conformance to
    this specification by successfully passing the test cases of the JSON-LD test
    suite [<cite><a class="bibref" href="#bib-JSON-LD-TESTS">JSON-LD-TESTS</a></cite>]. Note, however, that passing all the tests in the test
    suite does not imply complete conformance to this specification. It only implies
    that the implementation conforms to aspects tested by the test suite.</p></div>
</section>

<section id="general-terminology">
  
<!--OddPage-->
<h2><span class="secno">4. </span>General Terminology</h2>

  <p>This document uses the following terms as defined in JSON [<cite><a class="bibref" href="#bib-RFC4627">RFC4627</a></cite>]. Refer
    to the <em>JSON Grammar</em> section in [<cite><a class="bibref" href="#bib-RFC4627">RFC4627</a></cite>] for formal definitions.</p>

  <dl>
    <dt><dfn title="json_object" id="dfn-json_object">JSON object</dfn></dt>
    <dd>An object structure is represented as a pair of curly brackets
      surrounding zero or more key-value pairs. A key is a
      <a class="tref internalDFN" title="string" href="#dfn-string">string</a>. A single colon comes after each key, separating the
      key from the value. A single comma separates a value from a following
      key.</dd>
    <dt><dfn title="array" id="dfn-array">array</dfn></dt>
    <dd>An array structure is represented as square brackets surrounding zero
      or more values (or elements). Elements are separated by commas.
      In JSON, an array is an <em>ordered</em> sequence of zero or more values.
      While JSON-LD uses the same array representation as JSON,
      the collection is <em>unordered</em> by default. While order is
      preserved in regular JSON arrays, it is not in regular JSON-LD arrays
      unless specific markup is provided (see <a href="#sets-and-lists"></a>).</dd>
    <dt><dfn title="string" id="dfn-string">string</dfn></dt>
    <dd>A string is a sequence of zero or more Unicode characters,
      wrapped in double quotes, using backslash escapes (if necessary). A
      character is represented as a single character string.</dd>
    <dt><dfn title="number" id="dfn-number">number</dfn></dt>
    <dd>A number is similar to that used in most programming languages, except
      that the octal and hexadecimal formats are not used and that leading
      zeros are not allowed.</dd>
    <dt><dfn title="true" id="dfn-true">true</dfn> and <dfn title="false" id="dfn-false">false</dfn></dt>
    <dd>Values that are used to express one of two possible boolean states.</dd>
    <dt><dfn title="null" id="dfn-null">null</dfn></dt>
    <dd>The <a class="tref internalDFN" title="null" href="#dfn-null">null</a> value. A key-value pair in the
      <code>@context</code> where the value, or the <code>@id</code> of the
      value, is <a class="tref internalDFN" title="null" href="#dfn-null">null</a> explicitly decouples a term's association
      with an <abbr title="Internationalized Resource Identifier">IRI</abbr>. A key-value pair in the body of a JSON-LD document whose
      value is <a class="tref internalDFN" title="null" href="#dfn-null">null</a> has the same meaning as if the key-value pair
      was not defined. If <code>@value</code>, <code>@list</code>, or
      <code>@set</code> is set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a> in expanded form, then
      the entire <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> is ignored.</dd>
  </dl>

  <p>Furthermore, the following terminology is used throughout this document:</p>

  <dl>
    <dt><dfn title="keyword" id="dfn-keyword">keyword</dfn></dt>
    <dd>A JSON key that is specific to JSON-LD, specified in the JSON-LD Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>]
      in the section titled <cite><a href="../json-ld-syntax/#syntax-tokens-and-keywords">Syntax Tokens and Keywords</a></cite>.</dd>
    <dt><dfn title="context" id="dfn-context">context</dfn></dt>
    <dd>A a set of rules for interpreting a JSON-LD document as specified in
      <cite><a href="../json-ld-syntax/#the-context">The Context</a></cite> of the [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>] specification.</dd>
    <dt><dfn title="json-ld_document" id="dfn-json-ld_document">JSON-LD document</dfn></dt>
    <dd>A <a class="tref internalDFN" title="json-ld_document" href="#dfn-json-ld_document">JSON-LD document</a> is a serialization of a collection of
      <a class="tref internalDFN" title="json-ld_graph" href="#dfn-json-ld_graph">JSON-LD graphs</a> and comprises exactly one
      <a class="tref internalDFN" title="default_graph" href="#dfn-default_graph">default graph</a> and zero or more <a class="tref internalDFN" title="named_graph" href="#dfn-named_graph">named graphs</a>.</dd>
    <dt><dfn title="named_graph" id="dfn-named_graph">named graph</dfn></dt>
    <dd>A named graph is a pair consisting of an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>
      (the <dfn title="graph_name" id="dfn-graph_name">graph name</dfn>) and a <a class="tref internalDFN" title="json-ld_graph" href="#dfn-json-ld_graph">JSON-LD graph</a>.</dd>
    <dt><dfn title="default_graph" id="dfn-default_graph">default graph</dfn></dt>
    <dd>The default graph is the only graph in a JSON-LD document which has no <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.</dd>
    <dt><dfn title="json-ld_graph" id="dfn-json-ld_graph">JSON-LD graph</dfn></dt>
    <dd>A labeled directed graph, i.e., a set of <a class="tref internalDFN" title="node" href="#dfn-node">nodes</a> connected by <a class="tref internalDFN" title="edge" href="#dfn-edge">edges</a>,
      as specified in the <cite><a href="../json-ld-syntax/#data-model">Data Model</a></cite> section of the JSON-LD syntax
      specification [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>].</dd>
    <dt><dfn title="edge" id="dfn-edge">edge</dfn></dt>
    <dd>Every <a class="tref internalDFN" title="edge" href="#dfn-edge">edge</a> has a direction associated with it and is labeled with
      an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>. Within the JSON-LD syntax
      these edge labels are called <dfn title="property" id="dfn-property">properties</dfn>. Whenever possible, an
      <a class="tref internalDFN" title="edge" href="#dfn-edge">edge</a> <em class="rfc2119" title="should">should</em> be labeled with an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
    <dt><dfn title="node" id="dfn-node">node</dfn></dt>
    <dd>Every <a class="tref internalDFN" title="node" href="#dfn-node">node</a> is an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, a <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>,
      a <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD value</a>, or a <a class="tref internalDFN" title="list" href="#dfn-list">list</a>.</dd>
    <dt><dfn title="iri" id="dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt>
    <dd>An <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> (Internationalized Resource Identifier) is a string that conforms to the syntax
      defined in [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>].</dd>
    <dt><dfn title="absolute_iri" id="dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt>
    <dd>An absolute <abbr title="Internationalized Resource Identifier">IRI</abbr> is defined in [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>] containing a <em>scheme</em> along with a <em>path</em> and
      optional <em>query</em> and fragment segments.</dd>
    <dt><dfn title="relative_iri" id="dfn-relative_iri">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt>
    <dd>A relative <abbr title="Internationalized Resource Identifier">IRI</abbr> is an <abbr title="Internationalized Resource Identifier">IRI</abbr> that is relative some other <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>;
      in the case of JSON-LD this is the base location of the document.</dd>
    <dt><dfn title="blank_node" id="dfn-blank_node">blank node</dfn></dt>
    <dd>A <a class="tref internalDFN" title="node" href="#dfn-node">node</a> in a <a class="tref internalDFN" title="json-ld_graph" href="#dfn-json-ld_graph">JSON-LD graph</a> that does not contain a de-referenceable
      identifier because it is either ephemeral in nature or does not contain information that needs to be
      linked to from outside of the JSON-LD graph.</dd>
    <dt><dfn title="blank_node_identifier" id="dfn-blank_node_identifier">blank node identifier</dfn></dt>
    <dd>A blank node identifier is a string that can be used as an identifier for a <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a> within
      the scope of a JSON-LD document. Blank node identifiers begin with <code>_:</code>.</dd>
    <dt><dfn title="json-ld_value" id="dfn-json-ld_value">JSON-LD value</dfn></dt>
    <dd>A <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD value</a> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, a <a class="tref internalDFN" title="number" href="#dfn-number">number</a>,
      <a class="tref internalDFN" title="true" href="#dfn-true">true</a> or <a class="tref internalDFN" title="false" href="#dfn-false">false</a>, a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a>, or a
      <a class="tref internalDFN" title="language-tagged_string" href="#dfn-language-tagged_string">language-tagged string</a>.</dd>
    <dt><dfn title="typed_value" id="dfn-typed_value">typed value</dfn></dt>
    <dd>A <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a> consists of a value, which is a string, and a type, which is an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.
    </dd><dt><dfn title="language-tagged_string" id="dfn-language-tagged_string">language-tagged string</dfn></dt>
    <dd>A <a class="tref internalDFN" title="language-tagged_string" href="#dfn-language-tagged_string">language-tagged string</a> consists of a string and a non-empty language
      tag as defined by [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>]. The language tag must be well-formed according to section
      <a href="http://tools.ietf.org/html/bcp47#section-2.2.9">2.2.9</a> of [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>], and <em class="rfc2119" title="must">must</em>
      be normalized to lowercase.</dd>
    <dt><dfn title="list" id="dfn-list">list</dfn></dt>
    <dd>A <a class="tref internalDFN" title="list" href="#dfn-list">list</a> is an ordered sequence of <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a>,
      <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank nodes</a>, and
      <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD values</a>.</dd>
  </dl>
</section>

<section id="algorithms">

<!--OddPage-->
<h2><span class="secno">5. </span>Algorithms</h2>

<p>All algorithms described in this section are intended to operate on
  language-native data structures. That is, the serialization to a text-based
  JSON document isn't required as input or output to any of these algorithms and
  language-native data structures <em class="rfc2119" title="must">must</em> be used where applicable.</p>

<section id="algorithm-terms">
  <h3><span class="secno">5.1 </span>Algorithm Terms</h3>
  <dl>
    <dt><dfn title="active_graph" id="dfn-active_graph">active graph</dfn></dt>
    <dd>The name of the currently active graph that the processor should use when
      processing.</dd>
    <dt><dfn title="active_subject" id="dfn-active_subject">active subject</dfn></dt>
    <dd>The currently active subject that the processor should use when
      processing.</dd>
    <dt><dfn title="active_property" id="dfn-active_property">active property</dfn></dt>
    <dd>The currently active property that the processor should use when
      processing. The active property is represented in the original lexical form, which
      is used for finding type mappings in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>.</dd>
    <dt><dfn title="active_object" id="dfn-active_object">active object</dfn></dt>
    <dd>The currently active object that the processor should use when
      processing.</dd>
    <dt><dfn title="active_context" id="dfn-active_context">active context</dfn></dt>
    <dd>A context that is used to resolve <a class="tref internalDFN" title="term" href="#dfn-term">term</a>s while the processing
      algorithm is running. The <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> is the context
      contained within the <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a>.</dd>
    <dt><dfn title="local_context" id="dfn-local_context">local context</dfn></dt>
    <dd>A context that is specified within a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>,
      specified via the <code>@context</code> <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>.</dd>
    <dt><dfn title="processor_state" id="dfn-processor_state">processor state</dfn></dt>
    <dd>The <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a>, which includes the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active
      context</a>, <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, and
      <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>. The <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a> is managed
      as a stack with elements from the previous <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a>
      copied into a new <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a> when entering a new
      <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>.</dd>
    <dt><dfn title="json-ld_input" id="dfn-json-ld_input">JSON-LD input</dfn></dt>
    <dd>The JSON-LD data structure that is provided as input to the algorithm.</dd>
    <dt><dfn title="json-ld_output" id="dfn-json-ld_output">JSON-LD output</dfn></dt>
    <dd>The JSON-LD data structure that is produced as output by the algorithm.</dd>
    <dt><dfn title="term" id="dfn-term">term</dfn></dt>
    <dd>A <a class="tref internalDFN" title="term" href="#dfn-term">term</a> is a short word defined in a context that <em class="rfc2119" title="may">may</em> be expanded to an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a></dd>
    <dt><dfn title="compact_iri" id="dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt>
    <dd>A compact <abbr title="Internationalized Resource Identifier">IRI</abbr> is has the form of <dfn title="prefix" id="dfn-prefix">prefix</dfn>:<em>suffix</em> and is used as a way
      of expressing an <abbr title="Internationalized Resource Identifier">IRI</abbr> without needing to define separate <a class="tref internalDFN" title="term" href="#dfn-term">term</a> definitions for
      each <abbr title="Internationalized Resource Identifier">IRI</abbr> contained within a common vocabulary identified by <a class="tref internalDFN" title="prefix" href="#dfn-prefix">prefix</a>.</dd>
    <dt><dfn title="node_object" id="dfn-node_object">node object</dfn></dt>
    <dd>A <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node object</a> represents zero or more properties of a
      <a class="tref internalDFN" title="node" href="#dfn-node">node</a> in the <a class="tref internalDFN" title="json-ld_graph" href="#dfn-json-ld_graph">JSON-LD graph</a> serialized by the
      JSON-LD document. A <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> is a <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node object</a>
      if it exists outside of the JSON-LD <a class="tref internalDFN" title="context" href="#dfn-context">context</a> and:
      <ul>
        <li>it does not contain the <code>@value</code>, <code>@list</code>,
          or <code>@set</code> keywords, or</li>
        <li>it is not the top-level <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> in the JSON-LD document containing
          the <code>@graph</code> keyword.</li>
      </ul>
    </dd>
    <dt><dfn title="list_object" id="dfn-list_object">list object</dfn></dt>
    <dd>A <a class="tref internalDFN" title="list_object" href="#dfn-list_object">list object</a> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> that has a <code>@list</code>
      member.</dd>
    <dt><dfn title="scalar" id="dfn-scalar">scalar</dfn></dt>
    <dd>A scalar is either a JSON <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, <a class="tref internalDFN" title="number" href="#dfn-number">number</a>, <a class="tref internalDFN" title="true" href="#dfn-true">true</a>,
      or <a class="tref internalDFN" title="false" href="#dfn-false">false</a>.</dd>
    <dt><dfn title="quad" id="dfn-quad">quad</dfn></dt>
    <dd>An <em>RDF triple</em> as specified by [<cite><a class="bibref" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>] augmented with a a fourth component,
      a <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.</dd>
  </dl>
</section>

<section id="expansion-algorithm">
  <h3><span class="secno">5.2 </span>Expansion Algorithm</h3>

  <p>The algorithm takes three input variables: an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
    an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, and an <em>element</em> to be expanded. To
    begin, the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> is set to the result of performing, <a href="#context-processing">Context Processing</a> on the passed
    <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>,
    or empty if <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
    is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, and
    <em>element</em> is set to the <a class="tref internalDFN" title="json-ld_input" href="#dfn-json-ld_input">JSON-LD input</a>. This algorithm expects the
    <a class="tref internalDFN" title="json-ld_input" href="#dfn-json-ld_input">JSON-LD input</a> to be a well-formed JSON-LD document as defined in [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>].</p>

  <ol class="algorithm">
    <li>If <em>element</em> is a <a class="tref internalDFN" title="scalar" href="#dfn-scalar">scalar</a>, expand it according to the
      <a href="#value-expansion">Value Expansion</a> algorithm, passing copies of the
      <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> and return.</li>
    <li>If <em>element</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return.</li>
    <li>If <em>element</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>,
      <ol class="algorithm">
        <li>initialize an empty array <em>result</em>.</li>
        <li>Expand each <em>item</em> by recursively using this algorithm, passing copies of
          the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
        <li>If the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a>
          <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> is set to <code>@list</code> and the expanded
          <em>item</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> or a <a class="tref internalDFN" title="list_object" href="#dfn-list_object">list object</a> trigger
          a <code class="error">LIST_OF_LISTS_DETECTED</code> error.</li>
        <li>If the expanded <em>item</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, drop it.</li>
        <li>Otherwise, if the expanded <em>item</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, merge its
          entries with <em>result's</em> entries.</li>
        <li>Otherwise, append <em>item</em> to <em>result</em>.</li>
        <li>Finally, set <em>element</em> to <em>result</em> and return.</li>
      </ol>
    </li>
    <li>Otherwise, <em>element</em> must be an object.
      <ol class="algorithm">
        <li>If <em>element</em> has a <code>@context</code> member, update the
          <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> according to the steps outlined in
          <a href="#context-processing">Context Processing</a> and remove the
          <code>@context</code> member.</li>
        <li>Initialize an empty <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>result</em> and</li>
        <li>then process each <em>property</em> and <em>value</em> in <em>element</em>
          ordered by <em>property</em> as follows:
          <ol class="algorithm">
            <li>If the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> contains a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a> for
               <em>property</em> set <em>expanded property</em> to its <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a>,
               otherwise set it to the result of expanding <em>property</em> according to the steps
               outlined in <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</a> (passing <code>true</code> for
               the <em>vocabRelative</em> flag).</li>
            <li>If <em>expanded property</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, skip the 
              current <em>property</em>-<em>value</em> pair and continue to the
              next <em>property</em>-<em>value</em> pair in <em>element</em>.
            </li>
            <li>If <em>expanded property</em> is a <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>, process it as
              follows:
              <ol class="algorithm">
                <li>If <em>expanded property</em> equals <code>@id</code>, set the <code>@id</code>
                  member of <em>result</em> to the result of expanding <em>value</em>
                  according the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> (passing <code>true</code>
                  for the <em>documentRelative</em> flag). If <em>value</em> is not a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>
                  trigger an <code class="error">INVALID_ID_VALUE</code> error.</li>
                <li>If <em>expanded property</em> equals <code>@type</code>, set the <code>@type</code>
                  member of <em>result</em> to the result of expanding <em>value</em>
                  according the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> (passing <code>true</code>
                  for both the <em>documentRelative</em> and the <em>vocabRelative</em> flag). If <em>value</em>
                  is neither a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> nor an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> of
                  <a class="tref internalDFN" title="string" href="#dfn-string">strings</a> trigger an <code class="error">INVALID_TYPE_VALUE</code>
                  error. Empty <a class="tref internalDFN" title="array" href="#dfn-array">arrays</a> are ignored.</li>
                <li>If <em>expanded property</em> equals <code>@value</code>, set the <code>@value</code>
                  member of <em>result</em> to <em>value</em>. If <em>value</em> is neither a <a class="tref internalDFN" title="scalar" href="#dfn-scalar">scalar</a>
                  nor <a class="tref internalDFN" title="null" href="#dfn-null">null</a> trigger an <code class="error">INVALID_VALUE_OBJECT_VALUE</code> error.</li>
                <li>If <em>expanded property</em> equals <code>@language</code>, set the <code>@language</code>
                  member of <em>result</em> to the lowercased <em>value</em>. If <em>value</em> is not
                  a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, trigger an <code class="error">INVALID_LANGUAGE_VALUE</code> error.</li>
                <li>If <em>expanded property</em> equals <code>@annotation</code>, set the <code>@annotation</code>
                  member of <em>result</em> to <em>value</em>. If <em>value</em> is not a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>
                  trigger an <code class="error">INVALID_ANNOTATION_VALUE</code> error.</li>
                <li>If <em>expanded property</em> equals <code>@set</code> or <code>@list</code>, set the
                  <em>expanded property</em> member of <em>result</em> to the result of expanding <em>value</em> by
                  recursively using this algorithm, passing copies of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and
                  <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
                <li>If <em>expanded property</em> equals <code>@graph</code>, set the <code>@graph</code>
                  member of <em>result</em> to the result of expanding <em>value</em> by
                  recursively using this algorithm, passing copies of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and
                  <code>@graph</code> as <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
                <li>Continue with the next <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
              </ol>
            </li>
            <li>If <em>expanded property</em> is not an <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,i.e., it doesn't contain a colon,
              continue with the next member from <em>element</em>.</li>
            <li>Otherwise, if <em>property's</em> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> is set to
              <code>@language</code>
              <ol class="algorithm">
                <li>Initialize a new empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a> <em>language map values</em>.</li>
                <li>Process each <em>key</em>-<em>val</em> pair of <em>value</em> ordered by
                  <em>key</em> as follows:
                  <ol class="algorithm">
                    <li>If <em>val</em> is not an array, transform it to one.</li>
                    <li>For each item of <em>val</em>, construct a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
                      consisting of two members: <code>@value</code> set to the currently
                      processed item and <code>@language</code> set to the lowercased <em>key</em>.
                      If <em>val</em> is not a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, trigger a
                      <code class="error">LANGUAGE_MAP_INVALID_VALUE</code> error. Otherwise append
                      the object to <em>language map values</em>.</li>
                  </ol>
                </li>
                <li>Set <em>value</em> to <em>language map values</em>.</li>
              </ol>
            </li>
            <li>Otherwise, if <em>property's</em> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> is set to
              <code>@annotation</code>
              <ol class="algorithm">
                <li>Initialize a new empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a> <em>annotation map values</em>.</li>
                <li>Process each <em>key</em>-<em>val</em> pair of <em>value</em> ordered by
                  <em>key</em> as follows:
                  <ol class="algorithm">
                    <li>If <em>val</em> is not an array, transform it to one.</li>
                    <li>Expand <em>val</em> by recursively using this algorithm, passing copies of
                      the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
                    <li>Add to each item of <em>val</em> a member <code>@annotation</code> set to
                      <em>key</em> if no such member exists yet and append the resulting
                      <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> to <em>annotation map values</em>.</li>
                  </ol>
                </li>
                <li>Set <em>value</em> to <em>annotation map values</em>.</li>
              </ol>
            </li>
            <li>Otherwise, expand <em>value</em> by recursively using this algorithm, passing
              copies of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and <em>property</em> as
              <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
            <li>If the expanded <em>value</em> equals <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, continue with the next
              <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
            <li>If <em>property's</em> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> is set to <code>@list</code> and
              <em>value</em> is either not an <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> or a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
              without an <code>@list</code> member, replace <em>value</em> with a
              <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with an <code>@list</code> member whose value is set to
              <em>value</em> (wrapped in an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> if it is not already one).</li>
            <li>If <em>expanded property</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>,
              <ol class="algorithm">
                <li>label all <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank nodes</a> in <em>value</em> with
                  <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a> by using the
                  <a href="#label-blank-nodes-algorithm">Label Blank Nodes Algorithm</a>.</li>
                <li>Then, for each <em>iri</em> of <em>expanded property</em> merge a copy
                  of <em>value</em> into the <em>iri</em> member of the <em>result</em>
                  <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>.</li>
              </ol>
            </li>
            <li>Otherwise, merge <em>value</em> into the <em>iri</em> member of the <em>result</em>
              <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>.</li>
          </ol>
        </li>
        <li>Set <em>element</em> to <em>result</em> and <em>numProperties</em> to the number of members
          of <em>result</em>.</li>
        <li>If <em>element</em> has an <code>@annotation</code> member, decrease <em>numProperties</em>
          by 1.</li>
        <li>If <em>element</em> has an <code>@value</code> member,
          <ol class="algorithm">
            <li>decrease <em>numProperties</em> by 1.</li>
            <li>If <em>element</em> has an <code>@language</code> member, decrease <em>numProperties</em>
              by 1 and check that the value of the <code>@value</code> member is a string. If not,
              trigger an <code class="error">INVALID_LANGUAGE_TAGGED_STRING</code> error.</li>
            <li>Otherwise, if <em>element</em> has an <code>@type</code> member, decrease
              <em>numProperties</em> by 1 and check that the value of the <code>@type</code> member is a
              string. If not, trigger an <code class="error">INVALID_TYPED_VALUE</code> error.</li>
            <li>If <em>numProperties</em> is greater than 0, trigger an
              <code class="error">INVALID_VALUE_OBJECT</code> error.</li>
            <li>If the value of the <code>@value</code> member equals <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, set
              <em>element</em> to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
            <li>Return.</li>
          </ol>
        </li>
        <li>If <em>element</em> has an <code>@type</code> member whose value is not an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>,
          transform it to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
        <li>If <em>element</em> has an <code>@list</code> or <code>@set</code> member and
          <em>numProperties</em> is greater than 1, trigger an
          <code class="error">INVALID_SET_OR_LIST_OBJECT</code> error.</li>
        <li>Otherwise, if <em>element</em> has an <code>@set</code> member, set <em>element</em> to
          the value of that member.</li>
        <li>Otherwise, if <em>element</em> has just an <code>@language</code> member, set <em>element</em>
          to null.</li>
      </ol>
    </li>
  </ol>

  <p>If, after the algorithm outlined above is run, the resulting <em>element</em> is an
    <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with just a <code>@graph</code> member, <em>element</em> is set to
    the value of <code>@graph</code>'s value. Finally, if <em>element</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>,
    it is wrapped into an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</p>
</section>

<section typeof="bibo:Chapter" resource="#context" rel="bibo:chapter" id="context-processing">
  <h3 id="context"><span class="secno">5.3 </span>Context Processing</h3>

  <p>Processing of JSON-LD data structure is managed recursively. During processing, each
    rule is applied using information provided by the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>.</p>

  <p>The <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> contains the active <dfn title="term_definition" id="dfn-term_definition">term definitions</dfn>
    which specify how properties and values have to be interpreted as well as the current
    <dfn title="vocabulary_mapping" id="dfn-vocabulary_mapping">vocabulary mapping</dfn> and the <dfn title="default_language" id="dfn-default_language">default language</dfn>. Each <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a> consists
    of an <dfn title="iri_mapping" id="dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</dfn> and optionally a <dfn title="type_mapping" id="dfn-type_mapping">type mapping</dfn> from terms to datatypes or
    <dfn title="language_mapping" id="dfn-language_mapping">language mapping</dfn> from terms to language codes, and a <dfn title="container_mapping" id="dfn-container_mapping">container mapping</dfn>. If an
    <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> maps a term to multiple <tref="iri">IRIs it is said to be a
    <dfn title="property_generator" id="dfn-property_generator">property generator</dfn>.</tref="iri"></p>

  <p>If a <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> is encountered, information from the <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>
    is merged into the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>. A <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> is identified within
    a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> having a <code>@context</code> member with a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>,
    <a class="tref internalDFN" title="array" href="#dfn-array">array</a> or a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> value.</p>

  <p>This algorithm specifies how the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> is updated with a
    <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>. The algorithm takes three input variables: an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
    a <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>, and an array of already included remote contexts <em>remoteContexts</em>. To
    begin, <em>remoteContexts</em> is initialized to an empty array.</p>

  <p>All calls of the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> pass the value specified in the
    algorithm along with the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, the currently being processed <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>,
    and <code>true</code> for the <em>vocabRelative</em> flag.</p>

  <ol class="algorithm">
    <li>If the <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> is not an array, transform it to one.</li>
    <li>Process each item <em>context</em> of the <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> as follows:
      <ol class="algorithm">
        <li>If <em>context</em> equals <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, reset the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>
          and continue with the next item.</li>
        <li>If <em>context</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>:
          <ol class="algorithm">
            <li>Expand <em>context</em> according to <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</a>.</li>
            <li>If <em>context</em> is in the <em>remoteContexts</em> array, raise an
              <code class="error">RECURSIVE_CONTEXT_INCLUSION</code> error. Otherwise, add
              <em>context</em> to <em>remoteContexts</em>.</li>
            <li>Dereference <em>context</em>.</li>
            <li>If the resulting document is a JSON document consisting of a top-level
              <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> that has a <code>@context</code> member recursively invoke
              this algorithm passing a copy of <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, the value of the
              <code>@context</code> member as <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>, and a copy of
                the <em>remoteContexts</em> array. <a class="tref internalDFN" title="relative_iri" href="#dfn-relative_iri">Relative IRIs</a>
                are expanded using the remote context's <abbr title="Internationalized Resource Identifier">IRI</abbr>. Otherwise raise an
                <code class="error">INVALID_REMOTE_CONTEXT</code> error.</li>
            <li>Continue with the next item from <em>context</em>.</li>
          </ol>
        
<!--<li-->

        </li><li>If <em>context</em> is not a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, raise an
          <code class="error">INVALID_LOCAL_CONTEXT</code> error.</li>
        <li>Otherwise, if <em>context</em> is an <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, perform the following steps:
          <ol class="algorithm">
            <li>If <em>context</em> has a <code>@vocab</code> member: if its value is neither
              an <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, i.e., it does not contain a colon (<code>:</code>),
              nor <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, trigger an <code class="error">INVALID_VOCAB_MAPPING</code>
              error; otherwise set the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context's</a>
              <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a> to its value and remove the <code>@vocab</code>
              member from <em>context</em>.</li>
            <li>If <em>context</em> has a <code>@language</code> member: if its value is neither
              a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> nor <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, trigger an
              <code class="error">INVALID_DEFAULT_LANGUAGE</code> error; otherwise set the
              <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context's</a> <a class="tref internalDFN" title="default_language" href="#dfn-default_language">default language</a> to
              its value and remove the <code>@language</code> member from <em>context</em>.</li>
            <li>For each other <em>key</em>-<em>value</em> pair in <em>context</em> perform the
              following steps:
              <ol class="algorithm">
                <li>Remove the <em>key</em>-<em>value</em> pair from <em>context</em>.</li>
                <li>If <em>key</em> is a JSON-LD <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>, continue with the next
                  <em>key</em>-<em>value</em> pair.</li>
                <li>If <em>value</em> equals <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, replace the <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a>
                  for <em>key</em> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> with an <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
                  set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a> and continue with the next <em>key</em>-<em>value</em> pair.</li>
                <li>If <em>value</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, expand it according to the
                  <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> and replace the
                  <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a> for <em>key</em> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> with
                  an <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> set to the expanded <em>value</em>. Continue with
                  the next <em>key</em>-<em>value</em> pair.</li>
                <li>If <em>value</em> is not a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, trigger an
                  <code class="error">INVALID_TERM_DEFINITION</code> error</li>
                <li>If <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a> for <em>key</em> exists in the
                  <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, remove it.</li>
                <li>Initialize a new, empty <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a> <em>definition</em>.</li>
                <li>If <em>value</em> has an <code>@id</code> member with a value <em>val</em>:
                  <ol class="algorithm">
                    <li>if <em>val</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, set 
                    <em>definition</em> to <em>val</em>.
                    </li><li>if <em>val</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, process each 
                      <em>item</em> in the array:
                      <ol class="algorithm">
                        <li>if <em>item</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> expand it
                          according the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>.
                        </li>
                        <li>otherwise, raise an 
                          <code class="error">INVALID_PROPERTY_GENERATOR</code> 
                          error.
                        </li>
                      </ol>
                    </li><li>if <em>val</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, 
                      lexicographically sort <em>val</em> and set
                      <em>definition</em> to <em>val</em>.</li>
                    <li>Otherwise, if <em>val</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, 
                      expand it according the
                      <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> and
                      set <em>definition</em> to <em>val</em>. 
                    </li>
                  </ol>
                </li>
                <li>If the <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <em>definition</em> is set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a> or a
                  <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>, store the <em>definition</em> as the <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a>
                  for <em>key</em> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and continue with the next
                  <em>key</em>-<em>value</em> pair from <em>context</em>.</li>
                <li>Otherwise, set the <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <em>definition</em> to the result of
                  expanding <em>key</em> according the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>.</li>
                <li>If <em>value</em> has an <code>@type</code> member with a value <em>val</em> and <em>val</em>
                  is not a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> or does not expand to an <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> using the
                  <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, raise an
                  <code class="error">INVALID_TYPE_MAPPING</code> error. Otherwise set the
                  <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <em>definition</em> to the expanded <em>val</em>.</li>
                <li>Otherwise, if <em>value</em> has an <code>@language</code> member with a value <em>val</em>
                  that is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> or <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, set the <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> of
                  <em>definition</em> to the lowercased <em>val</em>. If <em>val</em> is neither a
                  <a class="tref internalDFN" title="string" href="#dfn-string">string</a> nor <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, raise an
                  <code class="error">INVALID_LANGUAGE_MAPPING</code> error.</li>
                <li>f <em>value</em> has an <code>@container</code> member with a value <em>val</em> that
                  equals <code>@list</code>, <code>@set</code>, or <code>@annotation</code>, set the
                  <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> of <em>definition</em> to <em>val</em>.
                  If <em>val</em> is not one of those values, raise an
                  <code class="error">INVALID_CONTAINER_MAPPING</code> error.</li>
              </ol>
            </li>
          </ol>
        </li>
      </ol>
    </li>
  </ol>
</section>

<section id="iri-expansion">
  <h3><span class="secno">5.4 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</h3>

  <p>In JSON-LD documents keys and some values are evaluated to produce an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.
    This section defines an algorithm for transforming strings representing an <abbr title="Internationalized Resource Identifier">IRI</abbr> into an
    <a class="tref internalDFN" title="absolute_iri" href="#dfn-absolute_iri">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>. If <abbr title="Internationalized Resource Identifier">IRI</abbr> expansion occurs during context processing, the
    <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> that is being processed is passed to this algorithm.
    After application of this algorithm, values processed by this algorithm are said to be
    in <dfn title="expanded_iri_form" id="dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</dfn>, although this may also include
    <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a> and
    JSON-LD <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keywords</a>.</p>

  <p>The algorithm takes two mandatory and four optional input variables: a <em>value</em>
    to be expanded, an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, two flags <em>documentRelative</em> and
    <em>vocabRelative</em> specifying whether <em>value</em> should be interpreted as
    <a class="tref internalDFN" title="relative_iri" href="#dfn-relative_iri">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> against the document's base <abbr title="Internationalized Resource Identifier">IRI</abbr> or the
    <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context's</a> <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a>,
    along with an <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> passed when this algorithm is used in
    <a href="#context-processing">Context Processing</a>, and finally an array
    <em>path</em> which is used to detect cyclic <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mappings</a>.
    If not passed, the two flags are set to <code>false</code> and <em>path</em> is
    initialized to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a> by default.</p>

  <p>The algorithm for generating an <abbr title="Internationalized Resource Identifier">IRI</abbr> is:</p>

  <ol class="algorithm">
    <li>If <em>value</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a> or a JSON-LD <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>, return
      <em>value</em> as is.</li>
    <li>If a <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> has been passed
      <ol class="algorithm">
        <li>and <em>value</em> is in the <em>path</em> array, raise a
          <code class="error">CYCLIC_IRI_MAPPING</code> error. Otherwise append <em>value</em>
          to <em>path</em>.</li>
        <li>If <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> contains an <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> for <em>value</em>
          that is not a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a> return the result of recursively calling
          this algorithm passing the <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> of the <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> as new
          <em>value</em>, the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>,
          <em>path</em>, and <code>true</code> for the <em>vocabRelative</em> flag. If the result
          is a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a>, raise an
          <code class="error">PROPERTY_GENERATOR_IN_TERM_DEFINITION</code> error.</li>
      </ol>
    </li>
    <li>If an <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> exists for <em>value</em> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>
      that is not a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a> return the value of the
      <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>.</li>
    <li>If <em>value</em> contains a colon (<code>:</code>), perform the following steps:
      <ol class="algorithm">
        <li>Split <em>value</em> into a <em>prefix</em> and <em>suffix</em> at the first occurrence of
          a colon (<code>:</code>).</li>
        <li>If <em>suffix</em> begins with <code>//</code> or <em>prefix</em> equals <code>_</code>,
          return <em>value</em> as is.</li>
        <li>If a <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> has been passed, expand <em>prefix</em> by recursively
          invoking this algorithm passing <em>prefix</em> as <em>value</em>, the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>
          and <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a>, <em>path</em>, and <code>true</code> for the
          <em>vocabRelative</em> flag. If the expanded <em>prefix</em> contains a colon (<code>:</code>)
          generate and return an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> by prepending the expanded <em>prefix</em> to the
          (possibly empty) <em>suffix</em> using textual concatenation.</li>
        <li>Otherwise, if the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> contains an <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> for
          <em>prefix</em> that is not a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a>, generate and return an
          <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> by prepending the <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> mapped to <em>prefix</em> to the
          (possibly empty) <em>suffix</em> using textual concatenation.</li>
      </ol>
    </li>
    <li>Otherwise, if the <em>vocabRelative</em> flag is set to <code>true</code> and the
      <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> contains a <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a>, generate and return an
      <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> by prepending the <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> of the <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a>
      to the <em>value</em> using textual concatenation.</li>
    <li>Otherwise, if the <em>documentRelative</em> flag is set to <code>true</code>, resolve <em>value</em>
      against the base <abbr title="Internationalized Resource Identifier">IRI</abbr> as per [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>] and return the resulting <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. Only the basic
      algorithm in section 5.2 of [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>] is used; neither <em>Syntax-Based Normalization</em>
      nor <em>Scheme-Based Normalization</em> (as described in sections 6.2.2 and 6.2.3 of [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>])
      are performed. Characters additionally allowed in <abbr title="Internationalized Resource Identifier">IRI</abbr> references are treated in the same way that
      unreserved characters are treated in URI references, per section 6.5 of [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>]</li>
    <li>Otherwise return <em>value</em> as is.</li>
  </ol>

  <p>If the result of the algorithm above is a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>, i.e., a string that begins with
    <code>_:</code>, and no <a class="tref internalDFN" title="local_context" href="#dfn-local_context">local context</a> has been passed,
    <a href="#generate-blank-node-identifier">generated a new blank node identifier</a> before returning the
    final result.</p>
</section>

<section id="value-expansion">
  <h3><span class="secno">5.5 </span>Value Expansion</h3>

  <p>Some values in JSON-LD can be expressed in a <a class="tref internalDFN" title="compacted_form" href="#dfn-compacted_form">compacted form</a>. These values
    are required to be expanded at times when processing JSON-LD documents.
    A value is said to be in <dfn title="expanded_form" id="dfn-expanded_form">expanded form</dfn> after
    the application of this algorithm.</p>

  <p>The algorithm for expanding a <em>value</em> takes an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
    and <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>. It is implemented as follows:</p>

  <ol class="algorithm">
    <li>If <em>value</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
    <li>Initialize an empty object <em>result</em>.</li>
    <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is <code>@graph</code> or the
      <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a> <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a> is set to
      <code>@id</code>, add a key-value pair to <em>result</em> where the key is <code>@id</code>
      and the value is the result of expanding <em>value</em> according to the
      <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> passing <code>true</code> for the
      <em>documentRelative</em> flag. Then return <em>result</em>.</li>
    <li>Add a key-value pair to <em>result</em> where the key is <code>@value</code>
      and the value is <em>value</em>.</li>
    <li>If the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> has a <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a>, add a key-value
      pair to <em>result</em> where the key is <code>@type</code> and the value is the
      <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> associated with the <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a> or a newly
      <a href="#generate-blank-node-identifier">generated blank node identifier</a> if the
      <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a> is set to a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>.</li>
    <li>Otherwise, if <em>value</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> and the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> has a
      <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> or an <a class="tref internalDFN" title="default_language" href="#dfn-default_language">default language</a> is set in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
      add a key-value pair to <em>result</em> where the key is <code>@language</code> and the value is the
      language tag associated with the <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> or the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> or the
      <a class="tref internalDFN" title="default_language" href="#dfn-default_language">default language</a>.</li>
    <li>Return <em>result</em>.</li>
  </ol>
</section>

<section id="label-blank-nodes-algorithm">
  <h3><span class="secno">5.6 </span>Label Blank Nodes Algorithm</h3>

  <p>The algorithm takes a single input variable: an <em>element</em> to be labeled with
    <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a>.</p>

  <ol class="algorithm">
    <li>If <em>element</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, recursively apply this
      algorithm to all its items.</li>
    <li>Otherwise, if <em>element</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with a
      <code>@list</code> member, recursively apply this algorithm to all items
      of the <code>@list</code> member's value.</li>
    <li>Otherwise, if <em>element</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
      <ol class="algorithm">
        <li>For each <em>key</em>-<em>value</em> pair ordered by <em>key</em>
          recursively apply this algorithm to <em>value</em>.</li>
        <li>If <em>element</em> is a <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node object</a> without an <code>@id</code> member,
          create a new <code>@id</code> member and assign it a new
          <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a> according the
          <a href="#generate-blank-node-identifier">Generate Blank Node Identifier</a> algorithm.</li>
      </ol>
    </li>
  </ol>
</section>

<section id="generate-blank-node-identifier">
  <h3><span class="secno">5.7 </span>Generate Blank Node Identifier</h3>

  <p>This algorithm is used to generate new
    <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a> or to relabel existing
    <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a> with a new one to avoid
    collision by the introduction of new ones. It needs to keep an <em>identifier map</em>,
    a <em>counter</em>, and a <em>prefix</em> between its executions to be able to generate new
    <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifiers</a>. The <em>counter</em>
    is initialized to <code>0</code> and <em>prefix</em> is set to <code>_:t</code> by default.</p>

  <p>The algorithm takes a single input variable <em>identifier</em> which might be
    <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</p>

  <ol class="algorithm">
    <li>If the <em>identifier</em> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a> and is in the <em>identifier map</em>,
      return the mapped identifier.</li>
    <li>Otherwise, generate a new <em>blankNodeIdentifier</em> by concatenating <em>prefix</em>
      and <em>counter</em>.</li>
    <li>Increment <em>counter</em> by <code>1</code>.</li>
    <li>If <em>identifier</em> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, create a new entry in
      <em>identifier map</em> set to <em>blankNodeIdentifer</em>.</li>
    <li>Return <em>blankNodeIdentifier</em>.</li>
  </ol>
</section>

<section id="compaction-algorithm">
  <h3><span class="secno">5.8 </span>Compaction Algorithm</h3>

  <p>The algorithm takes four input variables: an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
    an <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, and an <em>element</em>
    to be compacted. To begin, the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> is set to the result of performing
    <a href="#context-processing">Context Processing</a> on the passed <em>context</em>,
    <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a> is set to the result of
    <a href="#context-processing">creating an inverse context</a> from the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
    <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, and <em>element</em> is set to
    the result of performing the <a href="#expansion-algorithm">Expansion Algorithm</a>
    on the <a class="tref internalDFN" title="json-ld_input" href="#dfn-json-ld_input">JSON-LD input</a>.</p>

  <ol class="algorithm">
    <li>If <em>element</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>,
      <ol class="algorithm">
        <li>Initialize a new empty array <em>result</em>.</li>
        <li>Process each item in <em>element</em> recursively using this algorithm,
          passing a copy of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>,
          and the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>. Add each compacted item to <em>result</em>
          unless it is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
        <li>If <em>result</em> has a single item and the
          <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
          option is set to <code>true</code>, return that item; otherwise return
          <em>result</em>.</li>
      </ol>
    </li>
    <li>If <em>element</em> is not a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> it is already in
      compact form, return it as is.</li>
    <li>If <em>element</em> has an <code>@value</code> or <code>@id</code> member,
      replace <em>element</em> with the result of the
      <a href="#value-compaction">Value Compaction algorithm</a>. If the updated
      <em>element</em> is a <a class="tref internalDFN" title="scalar" href="#dfn-scalar">scalar</a>, return it as it cannot be further
      compacted.</li>
    <li>Initialize a new empty <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> result.</li>
    <li>Process each <em>property</em> and <em>value</em> in <em>element</em> ordered
      by <em>property</em> as follows:
      <ol class="algorithm">
        <li>If <em>property</em> is a JSON-LD <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>
          <ol class="algorithm">
            <li>and <em>property</em> equals <code>@id</code>, compact <em>value</em>
              according the rules of the <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>.</li>
            <li>Otherwise, if <em>property</em> equals <code>@type</code>, compact <em>value</em>
              (or each item of <em>value</em> if it is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>) according the rules of the
              <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a> with the
              <em>vocabRelative</em> flag set to <code>true</code>. If <em>value</em> is an
              <a class="tref internalDFN" title="array" href="#dfn-array">array</a> consisting of just one item, replace <em>value</em> with that item.</li>
            <li>Otherwise, if <em>property</em> equals <code>@graph</code>, compact <em>value</em>
              by recursively invoking this algorithm, passing a copy of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
              <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, and <em>property</em> as <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
              ensuring that the result is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
            <li>Set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the result of performing
              <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a> on <em>property</em>.</li>
            <li>Set the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member of <em>result</em> to <em>value</em>.</li>
            <li>Continue with the next <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
        
      </ol>
    </li>
    <li>If <em>value</em> is an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>,
      <ol class="algorithm">
        <li>set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the result of performing
          <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a> on <em>property</em> with the
          <em>vocabRelative</em> flag set to <code>true</code>.</li>
        <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, i.e., it is a
          <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a>, set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the result of performing the
          <a href="#find-and-remove-property-generator-duplicates">Find and Remove Property Generator Duplicates</a>
          algorithm passing <em>element</em>, <em>property</em>, <a class="tref internalDFN" title="null" href="#dfn-null">null</a> for value, the
          <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
        <li>Ensure that <em>result</em> has an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member; if not create it
          and set its value to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
        <li>Continue with the next <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
      </ol>
    </li>
    <li>Otherwise perform the following steps for each <em>item</em> of <em>value</em>:
      <ol class="algorithm">
        <li>Set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the result of performing
          <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a> on <em>property</em> with the
              <em>vocabRelative</em> flag set to <code>true</code>.</li>
        <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, i.e., it is a
          <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a>, set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the result of performing the
          <a href="#find-and-remove-property-generator-duplicates">Find and Remove Property Generator Duplicates</a>
          algorithm passing <em>element</em>, <em>property</em>, <em>item</em>, the
          <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
        
        <li>If the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a>
          is set to <code>@language</code> or <code>@annotation</code>
          <ol class="algorithm">
            <li>Unless <em>result</em> has already an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member, create one and
              initialize its value to an empty <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>. This object is called <em>mapObject</em>.</li>
            <li>Set <em>index</em> to the value of the <code>@language</code> or
              <code>@annotation</code> member of <em>item</em> (depending on the value of the
              <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a>).</li>
            <li>First compact <em>item</em> using the <a href="#value-compaction">Value Compaction algorithm</a>
              passing <em>index</em> as <em>containerValue</em>, then compact it by recursively invoking this
              algorithm passing a copy of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, and the
              <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
            <li>If no <em>index</em> member exists in the <em>mapObject</em> create one and set its value
              to <em>item</em>; otherwise append <em>item</em> to the <em>index</em> member (converting it to
              an array if it is not one already).</li>
            <li>Continue with the next <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
          </ol>
        </li>
        <li>If <em>item</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> having a <code>@list</code> member,
          <ol class="algorithm">
            <li>compact the value of that member by recursively invoking this algorithm passing
              a copy of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, and the
              <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> ensuring that the result is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
            <li>If the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a> <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a>
              is set to <code>@list</code>, set the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member of <em>result</em>
              to the value of <em>item's</em> <code>@list</code> member. If such an member already exists
              in result, raise an <code class="error">COMPACTION_TO_LIST_OF_LISTS</code> error; otherwise
              continue with the next <em>property</em>-<em>value</em> pair from <em>element</em>.</li>
          </ol>
        </li>
        <li>If <em>item</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, compact it by recursively
          invoking this algorithm passing a copy of the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
          <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, and the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
        <li>If no <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member exists in <em>result</em> create one and set its value
          to <em>item</em>; otherwise append <em>item</em> to the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member
          (converting it to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> if it is not one already).</li>
        <li>If the <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
          option is set to <code>false</code> or the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property's</a>
          <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> is set to <code>@list</code> or <code>@set</code>, convert the
          value of the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member of <em>result</em> to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> if
          it is not one already.</li>
      </ol>
    </li>
  </ol>

  <p>If, after the algorithm outlined above is run, the resulting <em>element</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>
    replace it with a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with a single member whose name is the result of
    compacting the value <code>@graph</code> with the <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
    and whose value is <em>element</em>. Finally, add a <code>@context</code> property to <em>element</em>
    and set it to the initially passed <em>context</em>.</p>
</li></ol></section>

<section id="iri-compaction-algorithm">
  <h3><span class="secno">5.9 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction Algorithm</h3>

  <p>This section defines an algorithm for transforming an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> to a
    <a class="tref internalDFN" title="term" href="#dfn-term">term</a> or <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>. If a <em>value</em> is passed
    it is used to choose the best matching <a class="tref internalDFN" title="term" href="#dfn-term">term</a>.</p>

  <p>This algorithm takes three mandatory and two optional parameters. The mandatory
    parameters are the <em>iri</em> to be compacted, an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
    and an <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>. Optionally it is possible to pass a <em>value</em>
    and a <em>vocabRelative</em> flag which specifies whether the passed <em>iri</em>
    should be compacted using the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context's</a>
    <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a>. If the <em>vocabRelative</em> flag is not set
    it defaults to <code>false</code>.</p>

  <p>The algorithm for generating a <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is:</p>

  <ol class="algorithm">
    <li>Initialize a variable <em>result</em> to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
    <li>If an entry for <em>iri</em> exists in the <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>,
      perform the following steps:
      <ol class="algorithm">
        <li>If a <em>value</em> has been passed, perform the following steps:
          <ol class="algorithm">
            <li>Initialize <em>queryPath</em>, which will be used to query the
              <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a></li>
            <li id="calculate-value-profile-algorithm">Initialize <em>container</em>
              to <code>@set</code>, <em>typeOrLanguage</em>, and <em>typeLanguageValue</em>
              to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
            <li>If <em>value</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
              <ol class="algorithm">
                <li>and it has an <code>@annotation</code> member, set <em>container</em> to
                  <code>@annotation</code>.</li>
                <li>If <em>value</em> has an <code>@id</code> member, set
                  <em>typeOrLanguage</em> to <code>@type</code> and <em>typeLanguageValue</em>
                  to <code>@id</code>.</li>
                <li>Otherwise, if <em>value</em> has an <code>@value</code> member,
                  <ol class="algorithm">
                    <li>and an <code>@type</code> member, set <em>typeOrLanguage</em> to
                      <code>@type</code> and <em>typeLanguageValue</em> to the value of the
                      <code>@type</code> member of <em>value</em>.</li>
                    <li>Otherwise, if it has an <code>@language</code> member, set
                      <em>typeOrLanguage</em> to <code>@language</code> and
                      <em>typeLanguageValue</em> to the value of the <code>@language</code>
                      member of <em>value</em>. If <em>value</em> has no <code>@annotation</code>
                      member, set <em>container</em> to <code>@language</code></li>
                    <li>Otherwise, if the value of <em>value's</em> <code>@value</code>
                      member is is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, set <em>typeOrLanguage</em> to
                      <code>@language</code> and <em>typeLanguageValue</em> to
                      <code>@null</code>.</li>
                  </ol>
                </li>
                <li>Otherwise, if <em>value</em> has an <code>@list</code> member,
                  <ol class="algorithm">
                    <li>If the <code>@list</code> member has at least one item, update
                      <em>container</em>, <em>typeOrLanguage</em>, and
                      <em>typeLanguageValue</em> by recursively running the steps
                      <a href="#calculate-value-profile-algorithm">2.1.2</a> to
                      2.1.3.4 (which will never be true since list of lists are not
                      allowed) of this algorithm passing the first item of <em>value's</em>
                      <code>@list</code> member as new <em>value</em>.</li>
                    <li>If <em>value</em> has no <code>@annotation</code> member, set
                      <em>container</em> to <code>@list</code>.</li>
                    <li>Starting from the second item of <em>value's</em> <code>@list</code>
                      member, recursively run the steps
                      <a href="#calculate-value-profile-algorithm">2.1.2</a> to
                      2.1.3.4 (which will never be true since list of lists are not
                      allowed) of this algorithm passing the item as new <em>value</em>. If
                      the resulting <em>typeOrLanguage</em> or <em>typeLanguageValue</em>
                      differ from the current value of <em>typeOrLanguage</em> or
                      <em>typeLanguageValue</em>, set both to <a class="tref internalDFN" title="null" href="#dfn-null">null</a> and stop
                      processing the <code>@list</code> items.</li>
                  </ol>
                </li>
              </ol>
            </li>
            <li>If the <em>container</em> equals <code>@list</code>, set the first item of
              <em>queryPath</em> to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> consisting of the two elements
              <code>@list</code> and <code>null</code>; otherwise set it to an array
              consisting of three elements where the first element is the value of <em>container</em>
               and the other two elements are <code>@set</code> and <code>@null</code>.</li>
            <li>If <em>typeOrLanguage</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, set the second and the the
              third item of <em>queryPath</em> to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> consisting of a
              single element <code>@null</code>.</li>
            <li>Otherwise, set the second item of <em>queryPath</em> to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>
              consisting of two elements where the first element is the value of
              <em>typeOrLanguage</em> and the second element is <code>@null</code>. Set the
              third item of <em>queryPath</em> to an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> whose first element
              <em>typeLanguageValue</em> and whose second element is <code>@null</code>.</li>
            <li><a href="#inverse-context-query-algorithm">Query the inverse context</a> and
              store the result in <em>result</em>.</li>
            <li>If <em>result</em> is a a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> or a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with a
              <code>term</code> member, return <em>result</em>.</li>
          </ol>
        </li>
        <li>Otherwise, if the entry for <em>iri</em> in the <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>
          has a <code>term</code> member, return its value.</li>
      </ol>
    </li>
    <li>For each <em>termIri</em>-<em>termDefinition</em> pair in <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>
      sorted in reverse order by <em>termIri</em> the (longest <em>termIri</em> comes first),
      perform the following steps:
      <ol class="algorithm">
        <li>If <em>termDefinition</em> does not have a <code>term</code> member, i.e., it is
          a property generator, continue with the next <em>termIri</em>-<em>termDefinition</em>
          pair from <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>.</li>
        <li>Otherwise, if <em>iri</em> begins with <em>termIri</em> and is longer than
          <em>termIri</em>, generate a <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> by concatenating the value
          of the <code>term</code> member of <em>termDefinition</em> with a colon
          (<code>:</code>) character and the unmatched part of <em>iri</em>.</li>
        <li>If the resulting <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> has an entry in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
          continue with the next <em>termIri</em>-<em>termDefinition</em> pair from
          <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a> as the <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> cannot be used.</li>
        <li>Otherwise, if result is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return the <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>; if it is
          not null, set the <code>term</code> member of <em>result</em> to the <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
          and return <em>result</em>.</li>
      </ol>
    </li>
    <li>If the <em>vocabRelative</em> flag is set to <code>true</code>, the
      <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> has a <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a>, and <em>iri</em>
      begins with the <abbr title="Internationalized Resource Identifier">IRI</abbr> of the <a class="tref internalDFN" title="vocabulary_mapping" href="#dfn-vocabulary_mapping">vocabulary mapping</a> but is longer
      <ol class="algorithm">
        <li>Set <em>vocabIri</em> to the unmatched part of <em>iri</em>.</li>
        <li>If there does not exist an entry for <em>vocabIri</em> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>,
          return <em>vocabIri</em> if <em>result</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>; if it is not
          <a class="tref internalDFN" title="null" href="#dfn-null">null</a> set the <code>term</code> member of <em>result</em> to
          <em>vocabIri</em> and return <em>result</em>.</li>
      </ol>
    </li>
    <li>If <em>result</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return <em>iri</em> as is.</li>
    <li>Otherwise set the <code>term</code> member of <em>result</em> to <em>iri</em> and
      return <em>result</em>.</li>
  </ol>
</section>

<section id="inverse-context-creation">
  <h3><span class="secno">5.10 </span>Inverse Context Creation</h3>

  <p>An <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> as produced by the
    <a href="#context-processing">Context Processing</a> algorithm is very
    efficient for <a href="#iri-expansion">expanding</a>
    <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> and <a class="tref internalDFN" title="compact_iri" href="#dfn-compact_iri">compact IRIs</a>
    to <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a> but is of limited use for the opposite
    operation: <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> compaction</a>. Hence,
    this algorithm introduces the notion of an <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>
    which brings the same efficiency to <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> compaction</a>.
    An <dfn title="inverse_context" id="dfn-inverse_context">inverse context</dfn> a tree of <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON objects</a>
    which allow to efficiently select a <a class="tref internalDFN" title="term" href="#dfn-term">term</a> for a <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>-value
    pair.</p>

  <p>The value takes an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> and returns the corresponding
    <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>.</p>

  <ol class="algorithm">
    <li>Set <em>defaultLanguage</em> to <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context's</a>default language if there is one; otherwise set it to <code>@null</code>.</li>
    <li>For each <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a> in the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>
      perform the following steps:
      <ol class="algorithm">
        <li>If the <a class="tref internalDFN" title="term" href="#dfn-term">term's</a> <a class="tref internalDFN" title="iri_mapping" href="#dfn-iri_mapping"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> is set to
          <a class="tref internalDFN" title="null" href="#dfn-null">null</a> continue with the next <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a>.</li>
        <li>Set <em>container</em> to the value of the <a class="tref internalDFN" title="term" href="#dfn-term">term's</a>
          <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> or <code>@null</code> if no such mapping exists.</li>
        <li>If the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> is a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a>, set <em>termType</em>
          to <code>propertyGenerators</code>.</li>
        <li>Otherwise set  set <em>termType</em> to <code>term</code> and append the
          <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to the <code>term</code> member of the <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> for
          the <a class="tref internalDFN" title="term" href="#dfn-term">term's</a> <abbr title="Internationalized Resource Identifier">IRI</abbr> in <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>
          (append <em>term</em> to <code>inverseContext[iri]['term']</code>).</li>
        <li>For each <em>iri</em> mapped to the <a class="tref internalDFN" title="term" href="#dfn-term">term</a>, perform the following steps:
          <ol class="algorithm">
            <li>If the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> has a <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a> to <em>type</em>,
              append the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to
              <code>inverseContext[iri][container]['@type'][type][termType]</code>, e.g.,
              <code>inverseContext['http://...']['@list']['@type']['http://...']['term']</code>.</li>
            <li>Otherwise, if the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> has a <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> store the
              associated language in <em>language</em>, replacing <a class="tref internalDFN" title="null" href="#dfn-null">null</a> with
              <code>@null</code>. Then append the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to
              <code>inverseContext[iri][container]['@language'][language][termType]</code>, e.g.,
              <code>inverseContext['http://...']['@list']['@language']['de']['term']</code>.</li>
            <li>Otherwise append the <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to
              <code>inverseContext[iri][container]['@null']['@null'][termType]</code> as well as
              <code>inverseContext[iri][container]['@language'][defaultLanguage][termType]</code>
              to take the <a class="tref internalDFN" title="default_language" href="#dfn-default_language">default language</a> into consideration for terms without
              explicit <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a>.</li>
          </ol>
        </li>
      </ol>
    </li>
    <li>Remove all but the shortest and lexicographically least <a class="tref internalDFN" title="term" href="#dfn-term">term</a> in each
      <code>term</code> member in <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>. The result is thus a single
      <a class="tref internalDFN" title="string" href="#dfn-string">string</a> value.</li>
    <li>Finally, sort the <a class="tref internalDFN" title="array" href="#dfn-array">array</a> associated with every <code>propertyGenerators</code> member in
      <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a> lexicographically (shortest <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> come
      first).</li>
  </ol>
</section>

<section id="inverse-context-query-algorithm">
  <h3><span class="secno">5.11 </span>Inverse Context Query Algorithm</h3>

  <p>It is possible that multiple <a class="tref internalDFN" title="term" href="#dfn-term">terms</a> that differ
    in their <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container</a>,
    <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type</a>, or <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> are
    mapped to the same <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. The purpose of this algorithm is to query
    the <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a> to return either the best matching <a class="tref internalDFN" title="term" href="#dfn-term">term</a>,
    or a list of potential <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generators</a>
    along with a <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to fall back to if none of the
    <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generators</a> can be applied.</p>

  <p>This algorithm takes an <em>inverseContextSubtree</em>, a <em>queryPath</em>
    as generated by the <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
    and a <em>level</em> parameter which is initialized to <code>0</code> if nothing else
    is passed. The algorithm returns either a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> representing the best matching
    <a class="tref internalDFN" title="term" href="#dfn-term">term</a> or a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> consisting of a
    <code>propertyGenerators</code> member, containing a sorted <a class="tref internalDFN" title="array" href="#dfn-array">array</a> of
    potential <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generators</a>,
    and an optional <code>term</code> member containing a <a class="tref internalDFN" title="term" href="#dfn-term">term</a> to fall back
    to if none of the <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generators</a>
    can be applied.</p>

  <ol class="algorithm">
    <li>Initialize <em>result</em> to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
    <li>If <em>level</em> equals <code>3</code>, i.e., the deepest nested
      <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> in the <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a> has been reached,
      perform the following steps:
      <ol class="algorithm">
        <li>If <em>inverseContextSubtree</em> has a <code>propertyGenerators</code> member,
          copy that member into a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> and store that object in
          <em>result</em>.</li>
        <li>If <em>inverseContextSubtree</em> has a <code>term</code> member and
          <em>result</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return the value of that member;
          otherwise <em>result</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, copy the <code>term</code>
          member into <em>result</em> and return <em>result</em>.</li>
      </ol>
    </li>
    <li>Otherwise, for each <em>entry</em> of the <a class="tref internalDFN" title="array" href="#dfn-array">array</a> in <em>queryPath's</em>
      <em>level'd</em> position (<code>queryPath[level]</code>), perform the following steps:
      <ol class="algorithm">
        <li>If <em>inverseContextSubtree</em> has no <em>entry</em> member, continue with
          the next <em>entry</em>.</li>
        <li>Otherwise set <em>tmpResult</em> to the result of recursively invoking this
          algorithm passing the <em>entry</em> member of <em>inverseContextSubtree</em> as
          new <em>inverseContextSubtree</em>, <em>queryPath</em>, and <em>level</em> + <code>1</code>
          as new <em>level</em>.</li>
        <li>If <em>tmpResult</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a> and <em>result</em> is
          <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return <em>tmpResult</em>; otherwise, if <em>result</em> is
          not <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, transform <em>tmpResult</em> to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
          whose <code>propertyGenerators</code> member is set to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>
          and whose <code>term</code> member is set to <em>tmpResult</em>.</li>
        <li>If <em>result</em> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, replace it with <em>tmpResult</em>.</li>
        <li>Otherwise, append each item of the <code>propertyGenerator</code> member of
          <em>tmpResult</em> to the <code>propertyGenerator</code> member of <em>result</em>
          unless it is already in <em>result's</em> member. If <em>result</em> has no
          <code>term</code> member but <em>tmpResult</em> does, copy <em>tmpResult's</em>
          <code>term</code> member into <em>result</em>.</li>
      </ol>
    </li>
    <li>Return <em>result</em>.</li>
  </ol>
</section>

<section id="value-compaction">
  <h3><span class="secno">5.12 </span>Value Compaction</h3>

  <p>Expansion transforms all values into <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a>in JSON-LD. This algorithm
    does the opposite, it compacts an algorithm according the <a class="tref internalDFN" title="term_definition" href="#dfn-term_definition">term definition</a>
    of the passed <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>. After the application of this algorithm a value
    is said to be in <dfn title="compacted_form" id="dfn-compacted_form">compacted form</dfn>.</p>

  <p>This algorithm takes a <em>value</em>, an <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, an
    <a class="tref internalDFN" title="inverse_context" href="#dfn-inverse_context">inverse context</a>, an <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, and an optional
    <em>containerValue</em>.</p>

  <ol class="algorithm">
    <li>If a <em>containerValue</em> has been passed, the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> has a
      <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> set to <code>@annotation</code> and <em>value</em>
      has an <code>@annotation</code> member which equals <em>containerValue</em>, remove that member.</li>
    <li>If <em>value</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> having a single member <code>@id</code>,
      return the result of performing <a href="#iri-compaction-algorithm"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a> on that
      member's value.</li>
    <li>Otherwise, if <em>value</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> having a <code>@value</code>
      member, perform the following steps:
      <ol class="algorithm">
        <li>If the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> has a <a class="tref internalDFN" title="type_mapping" href="#dfn-type_mapping">type mapping</a> and <em>value</em>
          has a corresponding <code>@type</code> member, remove the <code>@type</code> member
          from <em>value</em>.</li>
        <li>Otherwise, if the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> has a <a class="tref internalDFN" title="language_mapping" href="#dfn-language_mapping">language mapping</a> and
          <em>value</em> has a corresponding <code>@language</code> member, remove the
          <code>@language</code> member from <em>value</em>.</li>
        <li>Otherwise, if a <em>containerValue</em> has been passed, the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
          has a <a class="tref internalDFN" title="container_mapping" href="#dfn-container_mapping">container mapping</a> set to <code>@language</code>, and <em>value</em> has
          a <code>@language</code> member which equals <em>containerValue</em>, remove the
          <code>@language</code> member from <em>value</em>.</li>
        <li>Otherwise, if the <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a> has a <a class="tref internalDFN" title="default_language" href="#dfn-default_language">default language</a>
          <ol class="algorithm">
            <li>and the <em>value</em> has a corresponding <code>@language</code> member, remove the
              <code>@language</code> member from <em>value</em>.</li>
            <li>Otherwise, or if the value of <em>value's</em> <code>@value</code> member is a
              <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, return <em>value</em>.</li>
          </ol>
        </li>
        <li>If <em>value</em> has just a <code>@value</code> member, return the value of that
          member.</li>
      </ol>
    </li>
    <li>Return <em>value</em> as is.</li>
  </ol>
</section>

<section id="find-and-remove-property-generator-duplicates">
  <h3><span class="secno">5.13 </span>Find and Remove Property Generator Duplicates</h3>

  <p>This algorithm checks if a specific value exists for all <a class="tref internalDFN" title="iri" href="#dfn-iri">IRIs</a>
    associated with a <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a> and if so, it removes them. The
    algorithm takes five parameters: <em>element</em>, <em>property</em>, <em>value</em>,
    <a class="tref internalDFN" title="active_context" href="#dfn-active_context">active context</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</p>

  <ol class="algorithm">
    <li>For each item <em>propertyGenerator</em> of the <a class="tref internalDFN" title="array" href="#dfn-array">array</a> which is the
      value of the <code>propertyGenerators</code> member of <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> perform
      the following steps:
      <ol class="algorithm">
        <li>Check that a member exists for each <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> associated with the
          <em>propertyGenerator</em>. If <em>value</em> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a> also check
          whether each of those members that contains <em>value</em>. Values are considered to be equal
          if they are of the same type and have the same value(s); <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node objects</a>
          are considered to be equal if all members match, except if no <code>@id</code> member exists (i.e., it is
          an unlabeled <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>, in that case <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node objects</a> are never
          considered to be equal.
          </li>
        <li>If that's not the case, continue with the next <em>propertyGenerator</em>.</li>
        <li>Otherwise, remove <em>value</em> from every member. If the resulting value
          of a member is an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, remove the member altogether
          from <em>element</em>.</li>
        <li>Return <em>propertyGenerator</em>.</li>
      </ol>
    </li>
    <li>Return the value of the <code>term</code> member of <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
      since no matching <a class="tref internalDFN" title="property_generator" href="#dfn-property_generator">property generator</a> has been found.</li>
  </ol>
</section>

<section id="flattening-algorithm">
  <h3><span class="secno">5.14 </span>Flattening Algorithm</h3>

  <p>The algorithm takes two input variables, an <em>element</em> to flatten and a
    <em>context</em> used to compact the flattened document.</p>

  <ol class="algorithm">
    <li>Expand <em>element</em> according the
      <a href="#expansion-algorithm">Expansion algorithm</a>.</li>
    <li>Generate a <em>nodeMap</em> according the
      <a href="#node-map-generation">Node Map Generation algorithm</a>.</li>
    <li>Let <em>defaultGraph</em> be the value of the <code>@default</code> member of
      <em>nodeMap</em>; a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> representing the <a class="tref internalDFN" title="default_graph" href="#dfn-default_graph">default graph</a>.</li>
    <li>For each other <em>graphName</em>-<em>graph</em> pair in <em>nodeMap</em>
      perform the following steps:
      <ol class="algorithm">
        <li>If <em>defaultGraph</em> does not have a <em>graphName</em> member, create
          one and initialize its value to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> consisting of an
          <code>@id</code> member whose value is set to <em>graphName</em>.</li>
        <li>Add a <code>@graph</code> member set to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>
          (referred to as <em>nodes</em>) to the <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> which is the
          value of the <em>graphName</em> member of <em>nodeMap</em>.</li>
        <li>For each <em>id</em>-<em>node</em> pair in <em>graph</em> ordered by <em>id</em>,
          add <em>node</em> to the <em>nodes</em> <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
      </ol>
    </li>
    <li>Initialize an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a> flattened.</li>
    <li>For each <em>id</em>-<em>node</em> pair in <em>defaultGraph</em> ordered by <em>id</em>,
      add <em>node</em> to <em>flattened</em>.</li>
    <li>If <em>context</em> equals <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, return <em>flattened</em>.</li>
    <li>Otherwise, return the result of compacting <em>flattened</em> according the
      <a href="#compaction-algorithm">Compaction algorithm</a> passing <em>context</em>
      ensuring that the compaction result uses the <code>@graph</code> keyword (or its alias)
      at the top-level, even if the context is empty or if there is only one element to
      put in the <code>@graph</code> <a class="tref internalDFN" title="array" href="#dfn-array">array</a>. This ensures that the returned
      document has a deterministic structure.</li>
  </ol>
</section>

<section id="node-map-generation">
  <h3><span class="secno">5.15 </span>Node Map Generation</h3>

  <p>This algorithm creates a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>nodeMap</em> holding an indexed
    representation of the <a class="tref internalDFN" title="json-ld_graph" href="#dfn-json-ld_graph">graphs</a> and <a class="tref internalDFN" title="node" href="#dfn-node">nodes</a>
    represented in the passed, expanded document. All <a class="tref internalDFN" title="node" href="#dfn-node">nodes</a> that are not
    uniquely identified by an <abbr title="Internationalized Resource Identifier">IRI</abbr> get assigned a (new) <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>.
    The resulting <em>nodeMap</em> will have a member for every graph in the document whose
    value is another object with a member for every <a class="tref internalDFN" title="node" href="#dfn-node">node</a> represented in the document.
    The default graph is stored under the <code>@default</code> member, all other graphs are
    stored under their graph name.</p>

  <p>The algorithm takes as input an expanded JSON-LD document <em>element</em> and a reference to
    a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>nodeMap</em>. Furthermore it has the optional parameters
    <a class="tref internalDFN" title="active_graph" href="#dfn-active_graph">active graph</a> (which defaults to <code>@default</code>), an <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>,
    <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, and a reference to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>list</em>. The
    <em>nodeMap</em> must be initialized to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> consisting of a single member
    whose name corresponds with <a class="tref internalDFN" title="active_graph" href="#dfn-active_graph">active graph</a> and whose value is an empty <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>.</p>

  <ol class="algorithm">
    <li>If <em>element</em> is an array, process each entry in <em>element</em> recursively, using this algorithm
      and return.</li>
    <li>Otherwise <em>element</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>. Let <em>activeGraph</em> be the
      <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> which is the value of the <a class="tref internalDFN" title="active_graph" href="#dfn-active_graph">active graph</a> member of
      <em>nodeMap</em>.</li>
    <li>If it has a <code>@type</code> member, perform for each <em>item</em> the following
      steps:
      <ol class="algorithm">
        <li>If <em>item</em> is a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>, replace it with a
          <a href="#generate-blank-node-identifier">new blank node identifier</a>.</li>
        <li>If <em>activeGraph</em> has no member <em>item</em>, create it and initialize its
          value to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> consisting of a single member <code>@id</code>
          with the value <em>item</em>.</li>
      </ol>
    </li>
    <li>If <em>element</em> has an <code>@value</code> member, perform the following steps:
      <ol class="algorithm">
        <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>,
          <a href="#generate-blank-node-identifier">generate a blank node identifier</a> <em>id</em>
          and store <em>element</em> as value of the member <em>id</em> in <em>activeGraph</em>.
          <div class="issue"><div class="issue-title"><a href="https://github.com/json-ld/json-ld.org/issues/207"><span>Issue 207</span></a></div><p class="">Handling of free-floating values is still being discussed.</p></div></li>
        <li>Otherwise, if no <em>list</em> has been passed, merge <em>element</em> into the
          <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member of the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> in
          <em>activeGraph</em>.</li>
        <li>Otherwise, append <em>element</em> to the <code>@list</code> member of <em>list</em>.</li>
      </ol>
    </li>
    <li>Otherwise, if <em>element</em> has an <code>@list</code> member, perform
      the following steps:
      <ol class="algorithm">
        <li>Initialize a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>result</em> having a single member
          <code>@list</code> whose value is initialized to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
        <li>Recursively call this algorithm passing the value of <em>element's</em>
          <code>@list</code> member as new <em>element</em> and <em>result</em> as <em>list</em>.</li>
        <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is <a class="tref internalDFN" title="null" href="#dfn-null">null</a>,
          <a href="#generate-blank-node-identifier">generate a blank node identifier</a> <em>id</em>
          and store <em>result</em> as value of the member <em>id</em> in <em>activeGraph</em>.
          <div class="issue"><div class="issue-title"><a href="https://github.com/json-ld/json-ld.org/issues/207"><span>Issue 207</span></a></div><p class="">Handling of free-floating values is still being discussed.</p></div></li>
        <li>Otherwise, add <em>result</em> to the the value of the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member
          of the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> in <em>activeGraph</em>.</li>
      </ol>
    </li>
    <li>Otherwise <em>element</em> is a <a class="tref internalDFN" title="node_object" href="#dfn-node_object">node object</a>, perform the following
      steps:
      <ol class="algorithm">
        <li>If <em>element</em> has an <code>@id</code> member, store its value in <em>id</em> and remove
          the member from <em>element</em>. If <em>id</em> is a <a class="tref internalDFN" title="blank_node_identifier" href="#dfn-blank_node_identifier">blank node identifier</a>, replace it with
          <a href="#generate-blank-node-identifier">a new blank node identifier</a>.</li>
        <li>Otherwise <a href="#generate-blank-node-identifier">generate a new blank node identifier</a>
          and store it as <em>id</em>.</li>
        <li>If <em>activeGraph</em> does not contain a member <em>id</em>, create one and initialize
          it to a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> consisting of a single member <code>@id</code> whose
          value is set to <em>id</em>.</li>
        <li>If <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, perform the following steps:
          <ol class="algorithm">
            <li>Create a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> <em>reference</em> consisting of a single member
              <code>@id</code> whose value is <em>id</em>.</li>
            <li>If no <em>list</em> has been passed, merge <em>element</em> into the
              <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> member of the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> in
              <em>activeGraph</em>.</li>
            <li>Otherwise, append <em>element</em> to the <code>@list</code> member of <em>list</em>.</li>
          </ol>
        </li>
        <li>If <em>element</em> has an <code>@type</code> member, merge each value into the <code>@type</code>
          of <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> in <em>activeGraph</em>. Then remove the <code>@type</code> member
          from <em>element</em>.</li>
        <li>If <em>element</em> has an <code>@annotation</code> member, set the <code>@annotation</code>
          of <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> in <em>activeGraph</em> to its value. If such a member already
          exists in <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> and has a different value, raise a
          <code class="error">CONFLICTING_ANNOTATION</code> error. Otherwise continue and remove the
          <code>@annotation</code> from <em>element</em>.</li>
        <li>If <em>element</em> has an <code>@graph</code> member, recursively invoke this algorithm passing
          the value of the <code>@graph</code> member as new <em>element</em> and <em>id</em> as new
          <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>. Then remove the <code>@graph</code> member from <em>element</em>.</li>
        <li>Finally for each <em>property</em>-<em>value</em> pair in <em>element</em> ordered by
          <em>property</em> perform the following steps:
          <ol class="algorithm">
            <li>If no <em>property</em> member exists in the <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> which is the
              value of the <em>id</em> member of <em>activeGraph</em> create the member and initialize
              its value to an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
            <li>Recursively invoke this algorithm passing <em>value</em> as new <em>element</em>, <em>id</em>
              as new <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, and <em>property</em> as new <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.</li>
          </ol>
        </li>
      </ol>
    </li>
  </ol>
</section>

  <section id="rdf-conversion-algorithms">
    <h3><span class="secno">5.16 </span>RDF Conversion Algorithms</h3>

    <p>This specification describes algorithms to transform JSON-LD documents to an array of
      RDF <a class="tref internalDFN" title="quad" href="#dfn-quad">quads</a> and vice-versa. Note that many uses of JSON-LD
      may not require generation of RDF.</p>

    <p>The processing algorithms described in this section are provided in order to demonstrate
      how one might implement a JSON-LD to RDF processor. Conformant implementations are only
      required to produce the same type and number of <a class="tref internalDFN" title="quad" href="#dfn-quad">quads</a> but are
      not required to implement the algorithm exactly as described.</p>

    <div class="issue"><div class="issue-title"><span>Issue</span></div><p class="">This algorithm hasn't been updated yet.</p></div>

    <section id="convert-to-rdf-algorithm">
      <h4><span class="secno">5.16.1 </span>Convert to RDF Algorithm</h4>
      <p>
        The algorithm below is designed for in-memory implementations with random access to <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> elements.
      </p>
      <p>
        A conforming JSON-LD processor implementing RDF conversion <em class="rfc2119" title="must">must</em> implement a
        processing algorithm that results in the same set of RDF <a class="tref internalDFN" title="quad" href="#dfn-quad">quads</a> that the following
        algorithm generates:
      </p>

      <p>The algorithm takes four input variables: a <em>element</em> to be converted, an
        <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> and <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.
        To begin, the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> and <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>
        are set to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, and <em>element</em> is
        set to the result of performing the <a href="#expansion-algorithm">Expansion Algorithm</a> on
        the <a class="tref internalDFN" title="json-ld_input" href="#dfn-json-ld_input">JSON-LD input</a> which is expected to be a a well-formed JSON-LD document as defined in [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>].
        This removes any existing context to allow the given context to be cleanly applied.</p>

      <ol class="algorithm">
        <li id="processing-step-associative">
          If <em>element</em> is a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>, perform the following steps:
          <ol class="algorithm">
            <li>Set <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to <a class="tref internalDFN" title="null" href="#dfn-null">null</a>.</li>
            <li>
              If <em>element</em> has a <code>@value</code> property:
              <ol class="algorithm">
                <li>If the value of <code>@value</code> is a <a class="tref internalDFN" title="number" href="#dfn-number">number</a>, set the
                  <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a> using a <a class="tref internalDFN" title="canonical_lexical_form" href="#dfn-canonical_lexical_form">canonical lexical form</a>
                  of the value as defined in the section <a href="#data-round-tripping">Data Round Tripping</a>.
                  Set datatype to the value of the <code>@type</code> property if it exists, otherwise
                  either <code>xsd:integer</code> or <code>xsd:double</code>, depending
                  on if the value contains a fractional and/or an exponential component.</li>
                <li>Otherwise, if the value of <code>@value</code> is <strong>true</strong> or <strong>false</strong>,
                  set the <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a> created from the
                  <a class="tref internalDFN" title="canonical_lexical_form" href="#dfn-canonical_lexical_form">canonical lexical form</a> of the value. Set datatype to the value of the <code>@type</code>
                  property if it exists, otherwise <code>xsd:boolean</code>.</li>
                <li>
                  Otherwise, if <em>element</em> contains a <code>@type</code> property, set the
                  <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a>.
                </li>
                <li>
                  Otherwise, if <em>element</em> contains a <code>@language</code> property, set the
                  <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to a <a class="tref internalDFN" title="language-tagged_string" href="#dfn-language-tagged_string">language-tagged string</a>.
                </li>
                <li>
                  Otherwise, set the <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a>
                  using <code>xsd:string</code> as the datatype.
                </li>
              </ol>
            </li>
            <li>
              If <em>element</em> has a <code>@list</code> property the value <em class="rfc2119" title="must">must</em> be an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.
              Process its value as a list as described in <a href="#list-conversion">List Conversion</a> using
              the return value as the <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a>
            </li>
            <li>If <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a>:
              <ol class="algorithm">
                <li>If neither <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> nor <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> are <a class="tref internalDFN" title="null" href="#dfn-null">null</a>,
                  generate a <a class="tref internalDFN" title="quad" href="#dfn-quad">Quad</a>
                  representing <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>,
                  <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a>, and <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.</li>
                <li>Return <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a>.</li>
              </ol>
            </li>
            <li id="processing-step-subject">If <em>element</em> has a <code>@id</code> property,
              the value <em class="rfc2119" title="must">must</em> be a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, set the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> to the previously
              expanded value (either a <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a> or an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>).</li>
            <li>
              Otherwise, if <em>element</em> does not have a <code>@id</code> property, set the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active
              subject</a> to newly generated <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>.</li>
            <li>
              Process each <em>property</em> and <em>value</em> in <em>element</em>, ordered by
              <em>property</em>, as follows:
              <ol class="algorithm">
                <li>
                  If <em>property</em> is <code>@type</code>, set the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
                  to <code>rdf:type</code>.
                </li>
                <li>Otherwise, if <em>property</em> is <code>@graph</code>,
                  process <em>value</em> algorithm recursively, using <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> as <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>
                  and null values for <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a> and <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> and then
                  proceed to next property.</li>
                <li>Otherwise, if <em>property</em> is a <a class="tref internalDFN" title="keyword" href="#dfn-keyword">keyword</a>, skip this step.</li>
                <li>Otherwise, set <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> to the <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a> of <em>property</em>.</li>
                <li>Process <em>value</em> recursively using this algorithm, passing copies of
                  <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> and <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.
                </li>
              </ol>
            </li>
            <li>
              Set <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>.
            </li>
          </ol>
        </li>

        <li>Otherwise, if <em>element</em> is an <a class="tref internalDFN" title="array" href="#dfn-array">array</a>, process each value in the <a class="tref internalDFN" title="array" href="#dfn-array">array</a>
          as follows, process <em>element</em> recursively using this algorithm, using copies of
          <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, and <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.</li>

        <li>Otherwise, if <em>element</em> is a <a class="tref internalDFN" title="string" href="#dfn-string">string</a>, then the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
          must be <code>rdf:type</code> so set the <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> to an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</li>

        <li>If any of these steps created an <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> and neither <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>
          nor <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a> are <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, generate a <a class="tref internalDFN" title="quad" href="#dfn-quad">Quad</a> using
          <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>,<a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>, <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> and
          <a class="tref internalDFN" title="graph_name" href="#dfn-graph_name">graph name</a>.
        </li>
        <li>Return <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a>.</li>
      </ol>
    </section>

    <section id="list-conversion" typeof="bibo:Chapter" resource="#list-conversion" rel="bibo:chapter">
      <h4><span class="secno">5.16.2 </span>List Conversion</h4>

      <p>List Conversion is the process of taking an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> of values and adding them to a newly
        created <cite><a href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF Collection</a></cite> (see
        [<cite><a class="bibref" href="#bib-RDF-SCHEMA">RDF-SCHEMA</a></cite>]) by linking each element of the list using <code>rdf:first</code> and <code>rdf:next</code>,
        terminating the list with <code>rdf:nil</code> using the following sequence:</p>
      <p>The algorithm is invoked with an <a class="tref internalDFN" title="array" href="#dfn-array">array</a> <em>array</em>, the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
        and returns a value to be used as an <a class="tref internalDFN" title="active_object" href="#dfn-active_object">active object</a> in the calling location.</p>
      <div class="note"><div class="note-title"><span>Note</span></div><div class="">This algorithm does not support lists containing lists.</div></div>

      <div class="issue"><div class="issue-title"><span>Issue</span></div><p class="">This algorithm hasn't been updated yet.</p></div>

      <ol class="algorithm">
        <li>
          If <em>array</em> is empty return <code>rdf:nil</code>.
        </li>
        <li>
          Otherwise, generate a <a class="tref internalDFN" title="quad" href="#dfn-quad">Quad</a> using using the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>
          and a newly generated <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a> identified as <em>first <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a></em>.
        </li>
        <li>
          For each element in <em>array</em> other than the last element:
          <ol class="algorithm">
            <li>Create a processor state using
              <em>first blank node</em> as the <a class="tref internalDFN" title="active_subject" href="#dfn-active_subject">active subject</a>, and
              <code>rdf:first</code> as the <a class="tref internalDFN" title="active_property" href="#dfn-active_property">active property</a>.
              <ol class="algorithm">
                <li>Process the value starting at <a href="#processing-step-associative">Step 1</a>.</li>
                <li>Proceed using the previous <a class="tref internalDFN" title="processor_state" href="#dfn-processor_state">processor state</a>.</li>
              </ol>
            </li>
            <li>Unless this is the last element in <em>array</em>, generate a new <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a> identified as
              <em>rest blank node</em>, otherwise use <code>rdf:nil</code>.</li>
            <li>Generate a new <a class="tref internalDFN" title="quad" href="#dfn-quad">Quad</a> using <em>first blank node</em>,
              <code>rdf:rest</code> and <em>rest blank node</em>.</li>
            <li>Set <em>first blank node</em> to
              <em>rest blank node</em>.</li>
            <li>Return <em>first blank node</em>.</li>
          </ol>
        </li>
      </ol>
    </section>

    <section id="convert-from-rdf-algorithm">
      <h4><span class="secno">5.16.3 </span>Convert from RDF Algorithm</h4>
      <p>In some cases, data exists natively in the form of triples or or <a class="tref internalDFN" title="quad" href="#dfn-quad">quads</a>;
        for example, if the data was originally represented in an RDF graph or triple/quad store. This
        algorithm is designed to simply translate an array of <a class="tref internalDFN" title="quad" href="#dfn-quad">quads</a> into a
        JSON-LD document.</p>
      <p>When expanding <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed values</a> having a datatype of <code>xsd:string</code>,
        the <code>@type</code> <em class="rfc2119" title="must not">must not</em> be set to <code>xsd:string</code> and the resulting value
        <em class="rfc2119" title="must">must</em> have only a <code>@value</code> property.</p>

      <p>The conversion algorithm takes a single parameter <em>input</em> in the form of an
        array of <a class="tref internalDFN" title="quad" href="#dfn-quad">Quad</a> representations.</p>

      <div class="issue"><div class="issue-title"><span>Issue</span></div><p class="">This algorithm hasn't been updated yet.</p></div>

      <ol class="algorithm">
        <li id="new_graph">Construct <em>defaultGraph</em> as a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>
          containing <em>nodes</em> and <em>listMap</em>, each an empty <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a>.</li>
        <li>Construct <em>graphs</em> as a <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> containing <em>defaultGraph</em>
          identified by
          an empty <a class="tref internalDFN" title="string" href="#dfn-string">string</a>.</li>
        <li>For each <a class="tref internalDFN" title="quad" href="#dfn-quad">quad</a> in <em>input</em>:
          <ol class="algorithm">
            <li>Set <em>graph</em> to the entry in <em>graphs</em> identified
              by <em>name</em>, initializing it to a new entry using the mechanism
              described in <a href="#new_graph">Step 1</a>.</li>
            <li>If <em>property</em> is <code>rdf:first</code>,
              use the entry in <em>graph.listMap</em> indexed by <em>subject</em>,
              initializing it to a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> if nesessary. Represent
              <em>object</em> in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a>, as described in
              <a href="#value-expansion">Value Expansion</a>. Add the
              resulting <em>object representation</em> to the entry indexed by
              <em>first</em>, and skip to the next <a class="tref internalDFN" title="quad" href="#dfn-quad">quad</a>.</li>
            <li>If <em>property</em> is <code>rdf:rest</code>:
              <ol class="algorithm">
                <li>If <em>object</em> is a <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>, use the entry in
                  <em>graph.listMap</em> indexed by <em>subject</em>, initializing it
                  to a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> if necessary. Add the <em>nominalValue</em> of
                  <em>object</em> to the entry indexed by <em>rest</em>.
                </li>
                <li>Skip to the next <a class="tref internalDFN" title="quad" href="#dfn-quad">quad</a>.</li>
              </ol>
            </li>
            <li>If <em>name</em> is not <a class="tref internalDFN" title="null" href="#dfn-null">null</a>, and <em>defaultGraph.nodes</em>
              does not contain an entry for <em>name</em>,
              create a new entry for <em>name</em> from a new
              <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with key/value pair of <code>@id</code> and
              <em>name</em> represented in <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a>.</li>
            <li>Set <em>value</em> as the entry from <em>graph.nodes</em> for
              <em>subject</em>, initializing it to a new
              <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> with key/value pair of <code>@id</code> and
              <em>subject</em> represented in <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a> if necessary.</li>
            <li>If <em>property</em> is <code>rdf:type</code>, <em>object</em> is not a <a class="tref internalDFN" title="json-ld_value" href="#dfn-json-ld_value">JSON-LD value</a>, and the
              <code class="idlMemberName"><a href="#widl-JsonLdOptions-useRdfType">useRdfType</a></code>
              option is not present or <a class="tref internalDFN" title="false" href="#dfn-false">false</a>:
              <ol class="algorithm">
                <li>Append <em>object</em> represented in <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a> to the array value for the
                  key <code>@type</code>, creating an entry in <em>value</em> if necessary.</li>
              </ol>
            </li>

            <li>Otherwise, if <em>object</em> is a <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed value</a> and the
              <code class="idlMemberName"><a href="#widl-JsonLdOptions-useNativeTypes">useNativeTypes</a></code>
              option is set to <a class="tref internalDFN" title="true" href="#dfn-true">true</a>:
              <ol class="algorithm">
                <li>Generate a <em>converted value</em>:
                  <ol class="algorithm">
                    <li>If the literal's type is <code>xsd:boolean</code>, the
                      <em>converted value</em> is <a class="tref internalDFN" title="true" href="#dfn-true">true</a> if the literal
                      matches the value <code>true</code> or <code>false</code> if
                      the literal matches the value <code>false</code>.</li>
                    <li>If the literal's type is <code>xsd:integer</code> or
                      <code>xsd:double</code>, try to convert the literal to a
                      JSON <a class="tref internalDFN" title="number" href="#dfn-number">number</a>. If the conversion is successful,
                      store the result in <em>converted value</em>, otherwise
                      set <em>converted value</em> to <em>value</em>.</li>
                    <li>Otherwise, do not perform a conversion. Set
                      the <em>converted value</em> to the <em>value</em>.</li>
                  </ol>
                </li>
                <li>Append the <em>converted value</em> to the array value for the
                  key, creating an entry in <em>value</em> if necessary.</li>
              </ol>
            </li>

            <li>Otherwise, if <em>object</em> is <code>rdf:nil</code>:
              <ol class="algorithm">
                <li>Let <em>key</em> be <em>property</em> expressed in <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a>.</li>
                <li>Append an empty <code>@list</code> representation to the array value for
                  <em>key</em>, creating an entry in <em>value</em> if necessary.</li>
              </ol>
            </li>
            <li>Otherwise,
              <ol class="algorithm">
                <li>Let <em>key</em> be <em>property</em> expressed in <a class="tref internalDFN" title="expanded_iri_form" href="#dfn-expanded_iri_form">expanded <abbr title="Internationalized Resource Identifier">IRI</abbr> form</a> and let
                  <em>object representation</em>
                  be <em>object</em> represented in <a class="tref internalDFN" title="expanded_form" href="#dfn-expanded_form">expanded form</a> as described in
                  <a href="#value-expansion">Value Expansion</a>.</li>
                <li>If <em>object</em> is a <a class="tref internalDFN" title="blank_node" href="#dfn-blank_node">blank node</a>,
                  use the entry in <em>graph.listMap</em> indexed by <em>object</em>,
                  initializing it to a new <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> if nesessary.
                  Add an entry for <em>head</em> with <em>object representation</em>.</li>
                <li>Append <em>object representation</em> to the array value for
                  <em>key</em>, creating an entry in <em>value</em> if necessary.</li>
              </ol>
            </li>
          </ol>
        </li>
        <li>For each <em>name</em> and <em>graph</em> in <em>graphs</em>:
          <ol class="algorithm">
            <li>For each <em>subject</em> and <em>entry</em> in <em>graph</em>
              where <em>entry</em> has both <em>head</em> and <em>first</em> keys:
              <ol class="algorithm">
                <li>Set <em>value</em> to the value of <em>head</em> in <em>entry</em>.</li>
                <li>Remove the entry for <code>@id</code> in <em>value</em>.</li>
                <li>Add an entry to <em>value</em> for <code>@list</code> initialized to a new array
                  containing the value of <em>first</em> from <em>entry</em>.</li>
                <li>While <em>entry</em> has a key for <em>rest</em>:
                  <ol class="algorithm">
                    <li>Set <em>entry</em> to the value of <em>graph.listMap</em> for <em>entry.rest</em>.</li>
                    <li>Add the value for <em>entry.first</em> to the list array.</li>
                  </ol>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li>Create <em>array</em> as an empty <a class="tref internalDFN" title="array" href="#dfn-array">array</a>.</li>
        <li>For each <em>subject</em> and <em>entry</em> in <em>defaultGraph.nodes</em>
          ordered by <em>subject</em>:
          <ol class="algorithm">
            <li>Add <em>entry</em> to <em>array</em>.</li>
            <li>If <em>graphs</em> has an entry for <em>subject</em>, add a property
              <code>@graph</code> in <em>entry</em> containing the ordered entries
              from <em>graphs[subject].nodes</em>.</li>
          </ol>
        </li>
        <li>Return <em>array</em> as the result.</li>
      </ol>
    </section>

    <section id="data-round-tripping">
      <h4><span class="secno">5.16.4 </span>Data Round Tripping</h4>

      <p>When <a href="#rdf-conversion">converting JSON-LD to RDF</a> JSON-native types such as
        <em>numbers</em> and <em>booleans</em> are automatically coerced to <strong>xsd:integer</strong>,
        <strong>xsd:double</strong>, or <strong>xsd:boolean</strong>. Implementers <em class="rfc2119" title="must">must</em> ensure that the
        result is in <a class="tref internalDFN" title="canonical_lexical_form" href="#dfn-canonical_lexical_form">canonical lexical form</a>. A
        <dfn title="canonical_lexical_form" id="dfn-canonical_lexical_form">canonical lexical form</dfn> is a set of literals from among the valid set of literals for
        a datatype such that there is a one-to-one mapping between the <a class="tref internalDFN" title="canonical_lexical_form" href="#dfn-canonical_lexical_form">canonical lexical form</a> and a value
        in the value space as defined in [<cite><a class="bibref" href="#bib-XMLSCHEMA11-2">XMLSCHEMA11-2</a></cite>]. In other words, every value <em class="rfc2119" title="must">must</em> be converted
        to a deterministic <a class="tref internalDFN" title="string" href="#dfn-string">string</a> representation.</p>

      <p>The canonical lexical form of an <em>integer</em>, i.e., a number without fractions
        or a number coerced to <strong>xsd:integer</strong>, is a finite-length sequence of decimal
        digits (<code>0-9</code>) with an optional leading minus sign; leading zeroes are prohibited.
        To convert the number in JavaScript, implementers can use the following snippet of code:</p>

      <div class="example"><div class="example-title"><span>Example 12</span></div><pre class="example">(value).toFixed(0).toString()</pre></div>

      <p>The canonical lexical form of a <em>double</em>, i.e., a number with fractions
        or a number coerced to <strong>xsd:double</strong>, consists of a mantissa followed by the
        character &quot;E&quot;, followed by an exponent. The mantissa <em class="rfc2119" title="must">must</em> be a decimal number. The exponent
        <em class="rfc2119" title="must">must</em> be an integer. Leading zeroes and a preceding plus sign (<code>+</code>) are prohibited
        in the exponent. If the exponent is zero, it must be indicated by <code>E0</code>.
        For the mantissa, the preceding optional plus sign is prohibited and the decimal point is
        required. Leading and trailing zeroes are prohibited subject to the following: number
        representations must be normalized such that there is a single digit which is non-zero to the
        left of the decimal point and at least a single digit to the right of the decimal point unless
        the value being represented is zero. The canonical representation for zero is <code>0.0E0</code>.
        <strong>xsd:double</strong>'s value space is defined by the IEEE double-precision 64-bit
        floating point type [<cite><a class="bibref" href="#bib-IEEE-754-1985">IEEE-754-1985</a></cite>]; in JSON-LD the mantissa is rounded to 15 digits after the
        decimal point.</p>

      <p>To convert the number in JavaScript, implementers can use the following snippet of code:</p>

      <div class="example"><div class="example-title"><span>Example 13</span></div><pre class="example">(value).toExponential(15).replace(/(\d)0*e\+?/,'$1E')</pre></div>

      <div class="note"><div class="note-title"><span>Note</span></div><p class="">When data such as decimals need to be normalized, JSON-LD authors should
        not use values that are going to undergo automatic conversion. This is due to the lossy nature
        of <strong>xsd:double</strong> values. Authors should instead use the expanded object form to
        set the canonical lexical form directly.</p></div>

      <p>The canonical lexical form of the <em>boolean</em> values <code>true</code> and <code>false</code>
        are the strings <strong>true</strong> and <strong>false</strong>.</p>

      <p>When JSON-native <a class="tref internalDFN" title="number" href="#dfn-number">number</a>s, are type coerced, lossless data round-tripping can not
        be guaranted as rounding errors might occur. Additionally, only literals typed as
        <strong>xsd:integer</strong>, <strong>xsd:double</strong>, and  <strong>xsd:boolean</strong> are
        automatically converted back to their JSON-native counterparts in when
        <a href="#rdf-conversion">converting from RDF</a>.</p>

      <p>Some JSON serializers, such as PHP's native implementation in some versions,
        backslash-escape the forward slash character. For example, the value
        <code>http://example.com/</code> would be serialized as <code>http:\/\/example.com\/</code>.
        This is problematic as other JSON parsers might not understand those escaping characters.
        There is no need to backslash-escape forward slashes in JSON-LD. To aid interoperability
        between JSON-LD processors, a JSON-LD serializer <em class="rfc2119" title="must not">must not</em> backslash-escape forward slashes.</p>
    </section>
  </section>
</section>

<section id="the-application-programming-interface">
  
<!--OddPage-->
<h2><span class="secno">6. </span>The Application Programming Interface</h2>

  <p>This API provides a clean mechanism that enables developers to convert
  JSON-LD data into a a variety of output formats that are easier to work
  with in various programming languages. If a JSON-LD API is provided in
  a programming environment, the entirety of the following API <em class="rfc2119" title="must">must</em> be
  implemented.</p>

  <section id="jsonldprocessor">
    <h3><span class="secno">6.1 </span>JsonLdProcessor</h3>

    <p>The JSON-LD processor interface is the high-level programming structure that developers
      use to access the JSON-LD transformation methods.</p>

    <p>The JSON-LD API signatures are the same across all programming languages. Due
      to the fact that asynchronous programming is uncommon in certain languages, developers <em class="rfc2119" title="may">may</em>
      implement a processor with a synchronous interface instead. In that case, the <code>callback</code>
      parameter <em class="rfc2119" title="must not">must not</em> be included and the result <em class="rfc2119" title="must">must</em> be returned as a return value instead.</p>

    <p>It is important to highlight that conformant <a class="tref internalDFN" title="json-ld_processor" href="#dfn-json-ld_processor">JSON-LD processors</a>
      <em class="rfc2119" title="must not">must not</em> modify the input parameters.</p>

    <pre class="idl"><span class="idlInterface" id="idl-def-JsonLdProcessor">[<span class="extAttr">Constructor</span>]
interface <span class="idlInterfaceID">JsonLdProcessor</span> {
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-expand-void-object-object---DOMString-input-JsonLdCallback-callback-JsonLdOptions-options">expand</a></span> (<span class="idlParam"><span class="idlParamType">(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-compact-void-object-object---DOMString-input-object-DOMString-context-JsonLdCallback-callback-JsonLdOptions-options">compact</a></span> (<span class="idlParam"><span class="idlParamType">(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType">(<a>object</a> or <a>DOMString</a>)</span> <span class="idlParamName">context</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-JsonLdProcessor-flatten-void-object-object---DOMString-input-object-DOMString-context-JsonLdCallback-callback-JsonLdOptions-options">flatten</a></span> (<span class="idlParam"><span class="idlParamType">(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</span> <span class="idlParamName">input</span></span>, <span class="idlParam"><span class="idlParamType">(<a>object</a> or <a>DOMString</a>)?</span> <span class="idlParamName">context</span></span>, <span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></span> <span class="idlParamName">callback</span></span>, <span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
};</span></pre><section id="methods"><h4><span class="secno">6.1.1 </span>Methods</h4><dl class="methods"><dt id="widl-JsonLdProcessor-compact-void-object-object---DOMString-input-object-DOMString-context-JsonLdCallback-callback-JsonLdOptions-options"><code>compact</code></dt><dd>
        <a href="#compaction">Compacts</a> the given <code>input</code> using the
        <code>context</code> according to the steps in the
        <a href="#compaction-algorithm">Compaction Algorithm</a>.

        
      <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code>(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The JSON-LD object or array of JSON-LD objects to perform the compaction upon or an
            <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the JSON-LD document to compact.</td></tr><tr><td class="prmName">context</td><td class="prmType"><code>(<a>object</a> or <a>DOMString</a>)</code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The context to use when compacting the <code>input</code>; either in the
            form of an <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> or as <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on
            the given <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullTrue">✔</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options to configure the used algorithms such. This allows, e.g.,
            to set the input document's base <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. This also includes
            the <code>optimize</code> flag, which, if set, will allow processor-specific
            optimization.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-JsonLdProcessor-expand-void-object-object---DOMString-input-JsonLdCallback-callback-JsonLdOptions-options"><code>expand</code></dt><dd>
        <a href="#expansion">Expands</a> the given <code>input</code> according to
        the steps in the <a href="#expansion-algorithm">Expansion Algorithm</a>.

        
      <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code>(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The JSON-LD object or array of JSON-LD objects to perform the expansion upon or an
            <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the JSON-LD document to expand.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on
            the given <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullTrue">✔</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options to configure the used algorithms such. This allows, e.g.,
            to set the input document's base <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-JsonLdProcessor-flatten-void-object-object---DOMString-input-object-DOMString-context-JsonLdCallback-callback-JsonLdOptions-options"><code>flatten</code></dt><dd>
        <a href="#flattening">Flattens</a> the given <code>input</code> and
        <a href="#compaction">compacts</a> it using the passed <code>context</code>
          according to the steps in the <a href="#flattening-algorithm">Flattening Algorithm</a>.

        
      <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">input</td><td class="prmType"><code>(<a>object</a> or <a>object[]</a> or <a>DOMString</a>)</code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">The JSON-LD object or array of JSON-LD objects or an <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>
            referencing the JSON-LD document to flatten.</td></tr><tr><td class="prmName">context</td><td class="prmType"><code>(<a>object</a> or <a>DOMString</a>)</code></td><td class="prmNullTrue">✔</td><td class="prmOptFalse">✘</td><td class="prmDesc">The context to use when compacting the flattened <code>input</code>; either
            in the form of an <a class="tref internalDFN" title="json_object" href="#dfn-json_object">JSON object</a> or as <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. If
            <a class="tref internalDFN" title="null" href="#dfn-null">null</a> is passed, the result will not be compacted but keept
            in expanded form.</td></tr><tr><td class="prmName">callback</td><td class="prmType"><code><a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc">A callback that is called when processing is complete on the given
            <code>input</code>.</td></tr><tr><td class="prmName">options</td><td class="prmType"><code><a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a></code></td><td class="prmNullTrue">✔</td><td class="prmOptTrue">✔</td><td class="prmDesc">A set of options to configure the used algorithms such. This allows, e.g.,
            to set the input document's base <a class="tref internalDFN" title="iri" href="#dfn-iri"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></section>

  </section>

  <section id="callbacks">
    <h3><span class="secno">6.2 </span>Callbacks</h3>

    <p>JSON-LD processors utilize callbacks in order to return information in an
      asynchronous manner to calling applications. This section details the
      parameters sent to those callbacks.</p>

    <section id="jsonldcallback">
      <h4><span class="secno">6.2.1 </span>JsonLdCallback</h4>
      <p>The <a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a> is called when processing of an API method
        of <a href="#idl-def-JsonLdProcessor" class="idlType"><code>JsonLdProcessor</code></a> has been completed successfully or been
        terminated by an error.</p>

      <pre class="idl"><span class="idlCallback" id="idl-def-JsonLdCallback">callback <span class="idlCallbackID">JsonLdCallback</span> = <span class="idlCallbackType"><a>void</a></span> (<span class="idlParam"><span class="idlParamType"><a href="#idl-def-JsonLdProcessingError" class="idlType"><code>JsonLdProcessingError</code></a></span> <span class="idlParamName">error</span></span>, <span class="idlParam"><span class="idlParamType"><a>object or object</a>[]</span> <span class="idlParamName">document</span></span>);</span></pre><section><h5 id="callback-jsonldcallback-parameters">Callback <a class="idlType" href="#idl-def-JsonLdCallback"><code>JsonLdCallback</code></a> Parameters</h5><dl class="callback-members"><dt id="widl-JsonLdCallback-error"><code>error</code> of type <span class="idlMemberType"><a href="#idl-def-JsonLdProcessingError" class="idlType"><code>JsonLdProcessingError</code></a></span></dt><dd>If the value is <code>null</code>, then no error occurred. If
          the value is non-<code>null</code>, a processing error occurred
          and the details will be contained within the <code>error</code>
          object.</dd><dt id="widl-JsonLdCallback-document"><code>document</code> of type array of <span class="idlMemberType"><a>object or object</a></span></dt><dd>The processed JSON-LD document.</dd></dl></section>
    </section>
  </section>

  <section id="data-structures">
    <h3><span class="secno">6.3 </span>Data Structures</h3>
    <p>This section describes datatype definitions used within the JSON-LD API.</p>

    <section id="jsonldoptions">
      <h4><span class="secno">6.3.1 </span>JsonLdOptions</h4>
      <p>The <a href="#idl-def-JsonLdOptions" class="idlType"><code>JsonLdOptions</code></a> type is used to pass various options to the <a href="#idl-def-JsonLdProcessor" class="idlType"><code>JsonLdProcessor</code></a> methods.</p>
      <pre class="idl"><span class="idlDictionary" id="idl-def-JsonLdOptions">dictionary <span class="idlDictionaryID">JsonLdOptions</span> {
<span class="idlMember">    <span class="idlMemberType"><a>DOMString</a></span>           <span class="idlMemberName"><a href="#widl-JsonLdOptions-base">base</a></span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>object or DOMString</a></span> <span class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>boolean</a></span>             <span class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></span> = <span class="idlMemberValue">true</span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>boolean</a></span>             <span class="idlMemberName"><a href="#widl-JsonLdOptions-optimize">optimize</a></span> = <span class="idlMemberValue">false</span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>boolean</a></span>             <span class="idlMemberName"><a href="#widl-JsonLdOptions-useRdfType">useRdfType</a></span> = <span class="idlMemberValue">false</span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>boolean</a></span>             <span class="idlMemberName"><a href="#widl-JsonLdOptions-useNativeTypes">useNativeTypes</a></span> = <span class="idlMemberValue">true</span>;</span>
};</span></pre><section><h5 id="dictionary-jsonldoptions-members">Dictionary <a class="idlType" href="#idl-def-JsonLdOptions"><code>JsonLdOptions</code></a> Members</h5><dl class="dictionary-members"><dt id="widl-JsonLdOptions-base"><code>base</code> of type <span class="idlMemberType"><a>DOMString</a></span></dt><dd>The Base <abbr title="Internationalized Resource Identifier">IRI</abbr> to use when expanding the document. This overrides the value of
          <em>input</em> if it is a <a><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. If not specified and <em>input</em> is not
          an <a><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, the base <abbr title="Internationalized Resource Identifier">IRI</abbr> defaults to the current document <abbr title="Internationalized Resource Identifier">IRI</abbr> if in a browser context,
          or the empty string if there is no document context.
        </dd><dt id="widl-JsonLdOptions-compactArrays"><code>compactArrays</code> of type <span class="idlMemberType"><a>boolean</a></span>, defaulting to <code>true</code></dt><dd>If set to <code>true</code>, the JSON-LD processor replaces arrays with just
          one element with that element during compaction. If set to <code>false</code>,
          all arrays will remain arrays even if they have just one element.
        </dd><dt id="widl-JsonLdOptions-expandContext"><code>expandContext</code> of type <span class="idlMemberType"><a>object or DOMString</a></span>, defaulting to <code>null</code></dt><dd>A context that is used to initialize the active context when expanding a document.</dd><dt id="widl-JsonLdOptions-optimize"><code>optimize</code> of type <span class="idlMemberType"><a>boolean</a></span>, defaulting to <code>false</code></dt><dd>If set to <code>true</code>, the JSON-LD processor is allowed to
          optimize the output of the <a href="#compaction-algorithm">Compaction Algorithm</a>
          to produce even compacter representations. The algorithm for compaction
          optimization is beyond the scope of this specification and thus
          not defined. Consequently, different implementations <em class="rfc2119" title="may">may</em> implement
          different optimization algorithms.
        </dd><dt id="widl-JsonLdOptions-useNativeTypes"><code>useNativeTypes</code> of type <span class="idlMemberType"><a>boolean</a></span>, defaulting to <code>true</code></dt><dd>If set to <code>true</code>, the JSON-LD processor will try to convert
          <a class="tref internalDFN" title="typed_value" href="#dfn-typed_value">typed values</a> to JSON native types instead of using the
          expanded object form when <a href="#convert-from-rdf-algorithm">converting from RDF</a>.
          <code>xsd:boolean</code> values will be converted to <a class="tref internalDFN" title="true" href="#dfn-true">true</a> or <a class="tref internalDFN" title="false" href="#dfn-false">false</a>.
          <code>xsd:integer</code> and <code>xsd:double</code> values will be
          converted to
          <a class="tref internalDFN" title="number" href="#dfn-number">JSON numbers</a>.
        </dd><dt id="widl-JsonLdOptions-useRdfType"><code>useRdfType</code> of type <span class="idlMemberType"><a>boolean</a></span>, defaulting to <code>false</code></dt><dd>If set to <code>true</code>, the JSON-LD processor will use the
          expanded <code>rdf:type</code> <abbr title="Internationalized Resource Identifier">IRI</abbr> as the property instead of
          <code>@type</code> when <a href="#convert-from-rdf-algorithm">converting from RDF</a>.
        </dd></dl></section>
    </section>

    <section id="jsonldprocessingerror">
      <h4><span class="secno">6.3.2 </span>JsonLdProcessingError</h4>

      <div class="issue"><div class="issue-title"><a href="https://github.com/json-ld/json-ld.org/issues/153"><span>Issue 153</span></a></div><p class="">Developers should note that the details of
        error handling are being actively debated.</p></div>

      <p>The <a href="#idl-def-JsonLdProcessingError" class="idlType"><code>JsonLdProcessingError</code></a> type is used to report errors to a
        <a href="#idl-def-JsonLdCallback" class="idlType"><code>JsonLdCallback</code></a>.</p>

      <pre class="idl"><span class="idlDictionary" id="idl-def-JsonLdProcessingError">dictionary <span class="idlDictionaryID">JsonLdProcessingError</span> {
<span class="idlMember">    <span class="idlMemberType"><a href="#idl-def-JsonLdErrorCode" class="idlType"><code>JsonLdErrorCode</code></a></span> <span class="idlMemberName"><a href="#widl-JsonLdProcessingError-code">code</a></span>;</span>
<span class="idlMember">    <span class="idlMemberType"><a>DOMString</a>?</span>      <span class="idlMemberName"><a href="#widl-JsonLdProcessingError-message">message</a></span>;</span>
};</span></pre><section><h5 id="dictionary-jsonldprocessingerror-members">Dictionary <a class="idlType" href="#idl-def-JsonLdProcessingError"><code>JsonLdProcessingError</code></a> Members</h5><dl class="dictionary-members"><dt id="widl-JsonLdProcessingError-code"><code>code</code> of type <span class="idlMemberType"><a href="#idl-def-JsonLdErrorCode" class="idlType"><code>JsonLdErrorCode</code></a></span></dt><dd>a string representing the particular error type, as described in
          the various algorithms in this document.</dd><dt id="widl-JsonLdProcessingError-message"><code>message</code> of type <span class="idlMemberType"><a>DOMString</a></span>, nullable</dt><dd>an optional error message containing additional debugging information.
          The specific contents of error messages are outside the scope of this
          specification and thus implementation dependent.</dd></dl></section>
    </section>

    <section id="jsonlderrorcode">
      <h4><span class="secno">6.3.3 </span>JsonLdErrorCode</h4>
      <p>The JsonLdErrorCode represent the collection of valid JSON-LD error
        codes.</p>

      <pre class="idl"><span class="idlEnum" id="idl-def-JsonLdErrorCode">enum <span class="idlEnumID">JsonLdErrorCode</span> {
    &quot;<span class="idlEnumItem">INVALID_SYNTAX</span>&quot;,
    &quot;<span class="idlEnumItem">LOAD_ERROR</span>&quot;,
    &quot;<span class="idlEnumItem">LIST_OF_LISTS_DETECTED</span>&quot;
};</span></pre><table class="simple"><tr><th colspan="2">Enumeration description</th></tr><tr><td><code>INVALID_SYNTAX</code></td><td>A violation of the grammar as defined by the JSON-LD syntax specification
          [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>] was detected.</td></tr><tr><td><code>LOAD_ERROR</code></td><td>There was a problem encountered loading a remote context.</td></tr><tr><td><code>LIST_OF_LISTS_DETECTED</code></td><td>A list of lists was detected. List of lists are not supported in
          this version of JSON-LD due to the algorithmic complexity associated
          with conversion to RDF.</td></tr></table>
    </section>
  </section>
</section>

<section class="appendix" id="acknowledgements">
  
<!--OddPage-->
<h2><span class="secno">A. </span>Acknowledgements</h2>

  <p>A large amount of thanks goes out to the JSON-LD Community Group
    participants who worked through many of the technical issues on the mailing
    list and the weekly telecons - of special mention are Niklas Lindström,
    François Daoust, Lin Clark, and Zdenko 'Denny' Vrandečić.
    The editors would like to thank Mark Birbeck, who provided a great deal of
    the initial push behind the JSON-LD work via his work on RDFj.
    The work of Dave Lehn and Mike Johnson are appreciated for reviewing,
    and performing several implementations of the specification. Ian Davis is
    thanked for his work on RDF/JSON. Thanks also to Nathan Rixham,
    Bradley P. Allen, Kingsley Idehen, Glenn McDonald, Alexandre Passant,
    Danny Ayers, Ted Thibodeau Jr., Olivier Grisel, Josh Mandel, Eric Prud'hommeaux,
    David Wood, Guus Schreiber, Pat Hayes, Sandro Hawke, and Richard Cyganiak
    or their input on the specification.</p>
</section>



<section id="references" class="appendix" typeof="bibo:Chapter" resource="#references" rel="bibo:chapter">
<!--OddPage-->
<h2><span class="secno">B. </span>References</h2><section id="normative-references" typeof="bibo:Chapter" resource="#normative-references" rel="bibo:chapter"><h3><span class="secno">B.1 </span>Normative references</h3><dl class="bibliography" about=""><dt id="bib-IEEE-754-1985">[IEEE-754-1985]</dt><dd rel="dcterms:requires">IEEE. <cite>IEEE Standard for Binary Floating-Point Arithmetic.</cite> See <a href="http://standards.ieee.org/reading/ieee/std_public/description/busarch/754-1985_desc.html">http://standards.ieee.org/reading/ieee/std_public/description/busarch/754-1985_desc.html</a>
</dd><dt id="bib-JSON-LD">[JSON-LD]</dt><dd rel="dcterms:requires"><cite><a href="http://json-ld.org/spec/ED/json-ld-syntax/20120522/">The JSON-LD Syntax</a></cite> Manu Sporny, Gregg Kellogg, Markus Lanthaler Editors. World Wide Web Consortium (work in progress). 22 May 2012. Editor's Draft. This edition of the JSON-LD Syntax specification is http://json-ld.org/spec/ED/json-ld-syntax/20120522/. The <a href="http://json-ld.org/spec/latest/json-ld-syntax/">latest edition of the JSON-LD Syntax</a> is available at http://json-ld.org/spec/latest/json-ld-syntax/
</dd><dt id="bib-RDF-CONCEPTS">[RDF-CONCEPTS]</dt><dd rel="dcterms:requires"><cite><a href="http://www.w3.org/TR/2011/WD-rdf11-concepts-20110830/">RDF 1.1 Concepts and Abstract Syntax</a></cite> Richard Cyganiak, David Wood, Editors. World Wide Web Consortium (work in progress). 30 May 2012. Editor's Draft. This edition of the JSON-LD Syntax specification is http://www.w3.org/TR/2011/WD-rdf11-concepts-20110830/. The <a href="http://www.w3.org/TR/rdf11-concepts/">latest edition of the JSON-LD Syntax</a> is available at http://www.w3.org/TR/rdf11-concepts/
</dd><dt id="bib-RDF-SCHEMA">[RDF-SCHEMA]</dt><dd rel="dcterms:requires">Dan Brickley; Ramanathan V. Guha. <a href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210"><cite>RDF Vocabulary Description Language 1.0: RDF Schema.</cite></a> 10 February 2004. W3C Recommendation. URL: <a href="http://www.w3.org/TR/2004/REC-rdf-schema-20040210">http://www.w3.org/TR/2004/REC-rdf-schema-20040210</a> 
</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd rel="dcterms:requires">S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119.  URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a> 
</dd><dt id="bib-RFC3986">[RFC3986]</dt><dd rel="dcterms:requires">T. Berners-Lee; R. Fielding; L. Masinter. <a href="http://www.ietf.org/rfc/rfc3986.txt"><cite>Uniform Resource Identifier (URI): Generic Syntax.</cite></a> January 2005. Internet RFC 3986. URL: <a href="http://www.ietf.org/rfc/rfc3986.txt">http://www.ietf.org/rfc/rfc3986.txt</a> 
</dd><dt id="bib-RFC3987">[RFC3987]</dt><dd rel="dcterms:requires">M. Dürst; M. Suignard. <a href="http://www.ietf.org/rfc/rfc3987.txt"><cite>Internationalized Resource Identifiers (IRIs).</cite></a> January 2005. Internet RFC 3987. URL: <a href="http://www.ietf.org/rfc/rfc3987.txt">http://www.ietf.org/rfc/rfc3987.txt</a> 
</dd><dt id="bib-RFC4627">[RFC4627]</dt><dd rel="dcterms:requires">D. Crockford. <a href="http://www.ietf.org/rfc/rfc4627.txt"><cite>The application/json Media Type for JavaScript Object Notation (JSON)</cite></a> July 2006. Internet RFC 4627. URL: <a href="http://www.ietf.org/rfc/rfc4627.txt">http://www.ietf.org/rfc/rfc4627.txt</a>
</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd rel="dcterms:requires"><cite><a href="http://www.w3.org/TR/2012/CR-WebIDL-20120419/">Web IDL</a></cite> Cameron McCormack, Editor. World Wide Web Consortium. 19 April 2012. Candidate Recommendataion. This edition of Web IDL is http://www.w3.org/TR/2012/CR-WebIDL-20120419/. The <a href="http://dev.w3.org/2006/webapi/WebIDL/">latest edition of Web IDL</a> is available at http://dev.w3.org/2006/webapi/WebIDL/
</dd><dt id="bib-XMLSCHEMA11-2">[XMLSCHEMA11-2]</dt><dd rel="dcterms:requires">Henry S. Thompson; et al. <a href="http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/"><cite>W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes.</cite></a> 5 April 2012. W3C Recommendation URL: <a href="http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/">http://www.w3.org/TR/2012/REC-xmlschema11-2-20120405/</a> 
</dd></dl></section><section id="informative-references" typeof="bibo:Chapter" resource="#informative-references" rel="bibo:chapter"><h3><span class="secno">B.2 </span>Informative references</h3><dl class="bibliography" about=""><dt id="bib-BCP47">[BCP47]</dt><dd rel="dcterms:references">A. Phillips; M. Davis. <a href="http://tools.ietf.org/html/bcp47"><cite>Tags for Identifying Languages</cite></a> September 2009. IETF Best Current Practice. URL: <a href="http://tools.ietf.org/html/bcp47">http://tools.ietf.org/html/bcp47</a> 
</dd><dt id="bib-ECMA-262">[ECMA-262]</dt><dd rel="dcterms:references"><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm"><cite>ECMAScript Language Specification.</cite></a> June 2011. URL: <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">http://www.ecma-international.org/publications/standards/Ecma-262.htm</a> 
</dd><dt id="bib-JSON-LD-TESTS">[JSON-LD-TESTS]</dt><dd rel="dcterms:references"><cite><a href="http://dvcs.w3.org/hg/json-ld/raw-file/default/test-suite/">JSON-LD Test Suite</a></cite> (work in progress).
</dd><dt id="bib-TURTLE-TR">[TURTLE-TR]</dt><dd rel="dcterms:references">Eric Prud'hommeaux, Gavin Carothers. <cite><a href="http://www.w3.org/TR/2011/WD-turtle-20110809/">Turtle: Terse RDF Triple Language.</a></cite> 09 August 2011. W3C Working Draft. URL: <a href="http://www.w3.org/TR/2011/WD-turtle-20110809/">http://www.w3.org/TR/2011/WD-turtle-20110809/</a>
</dd></dl></section></section></body></html>
